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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating auto-increment primary key 1

Status
Not open for further replies.

Guest_imported

New member
Jan 1, 1970
0
I want to create a table in wich its primary key will be auto incremented.

I tried

CREATE TABLE table_name (id INT, name TEXT, PRIMATY KEY id AUTO_INCREMENT);

but that doesn´t work.
 
choose serial as the datatype

this will create a sequence and the next vlaue of the serial will be set to that.

sequences can be listed by using \d s

the default for the serial will be set to nextval('sequence name')
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top