Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Support for Auto Increment Column.

Status
Not open for further replies.

vpshriyan

IS-IT--Management
Jul 26, 2002
356
IN
Hi,

A similar kind of data type is available, called SERIAL. You may specify the initial starting number as starting seed number (default 1) One need to pass a fixed value 0 for the serial type columns; so that the database server can generate to next sequence number in ascending order. If you insert any other number, it will be accepted as it is & will be stored in the table. If you need to maintain a unique sequence of numbers; you should implement an unique index on the column.

Example:

create temp table tab1 (f1 serial) with no log ;
insert into tab1 values (0) ;
-- show the generated sequence number.
select dbinfo('sqlca.sqlerrd1') from systables where tabid=1 ;

Regards,
Shriyan
 

Hi,

Thanks for your reply,

1. To add on , is the serial column applicable only for the temporary tables?


2. Can we alter a serial column, if so can i just get the corresponding alter statement

Regards

Stephen
 
Hi,

1. SERIAL column is applicable on both base and temp tables.
2. Yes. alter table tab1 modify f1 int

Regards,
Shriyan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top