Creating a column to auto increment

Nige's profile image Nige posted 5 years ago in General Permalink

Hi to everyone,

I only installed HeidiSQL the other day while testing some different software to use for my project. Anyway I have created a table my first column is called "id" data type is "int" I need this column to auto increment. Does someone mind telling me how to do this to save me some time?

Thanks Nige

ansgar's profile image ansgar posted 5 years ago Permalink
  • click the Default value, which should display "No default" currently
  • in the popup dialog, select AUTO_INCREMENT
  • click OK
  • rightclick the column name "id"
  • point to "Create new index", then click "Primary key"
  • click "Save", or add further columns
Nige's profile image Nige posted 5 years ago Permalink

Hi Ansgar, thanks for the super fast reply. I have been working with MSSQL for as long as so Im used to SQL Management studio. But now it looks like I will be using MYSQL a lot more, anyway thanks Nige.

cicero.neto's profile image cicero.neto posted 2 years ago Permalink

For PostGreSQL this work?

UweKeim's profile image UweKeim posted 2 years ago Permalink

Unfortunately I always got "Syntax error" messages, so I created the table together with the autoincrement ID field through the psql command line as described in postgresqltutorial .com/postgresql-tutorial/postgresql-serial/:

CREATE TABLE MyTableName (id SERIAL);

Once this went through, I did an UI refresh in HeidiSQL and continued to add the other columns in the HeidiSQL GUI.

Please login to leave a reply, or register at first.