Link to home
Start Free TrialLog in
Avatar of yue520
yue520

asked on

Create sequence to auto increment index

I am new to postgresql. I know it doesn't do auto increment on index. I am not sure how to say this: how do I create a sequence on command line so that I can get the next index # in my table FILE_RECORD.

Thanks a lot

Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

create table x ( the_index_column serial );
create table y ( the_index_column bigserial );
insert into x ( the_index ) values ( default );
insert into y ( the_index ) values ( default );
Doh that should be
create table x ( the_index_column serial );
create table y ( the_index_column bigserial );
insert into x ( the_index_column ) values ( default );
insert into y ( the_index_column ) values ( default );
ASKER CERTIFIED SOLUTION
Avatar of earth man2
earth man2
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial