Re: create index on a field of udt

From: John R Pierce <pierce(at)hogranch(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: create index on a field of udt
Date: 2015-06-29 05:23:34
Message-ID: 5590D656.2070705@hogranch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 6/28/2015 10:08 PM, Shujie Shang wrote:
> create type info as (id int, name text);
> I want to create index on info.id <http://info.id>.
>

you can't create an index on a type, just on a table.

create table info (id serial primary key, name text);

or

create table info (id serial, name text);
alter table info add primary key(id);

or more generically,

create index on some_table ( some_field[,...] ) ;

(a primary key is a unique not null constraint, this implies an index in
postgresql)

--
john r pierce, recycling bits in santa cruz

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Shujie Shang 2015-06-29 05:31:28 Re: create index on a field of udt
Previous Message Shujie Shang 2015-06-29 05:08:51 create index on a field of udt