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

issue with primary key and AUTO_INCREMENT...need explanation...

Status
Not open for further replies.

spewn

Programmer
May 7, 2001
1,034

i want to figure out how to use auto increment. assigned the column as a primary key and changed the data type to int. no too familiar with 'primary key'. auto increment seems self explanatory.

is this correct so far? my goal is to have the auto increment field do just that; automatically increment as i insert new columns.

how do i go about this?

- g
 
You've done it correctly. Whether it's a good idea or not is debatable.
 
create table TABLENAME (

id_number int not null primary key auto_increment,
blah tinytext,
etc
etc
)

will have the first column id_number and the primary key of type int and will automatically increment with eact new entry to the table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top