Re: create index on a field of udt - Mailing list pgsql-general

From John R Pierce
Subject Re: create index on a field of udt
Date
Msg-id 5590D656.2070705@hogranch.com
Whole thread Raw
In response to create index on a field of udt  (Shujie Shang <sshang@pivotal.io>)
Responses Re: create index on a field of udt  (Shujie Shang <sshang@pivotal.io>)
List 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.


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

pgsql-general by date:

Previous
From: Shujie Shang
Date:
Subject: create index on a field of udt
Next
From: Shujie Shang
Date:
Subject: Re: create index on a field of udt