sql - Database auto-increment column -


Is it possible to create a database that has 1 column (but not a primary key column) that is auto- Ho? So when I insert the value to the database, I do not need to fill my value, and DB will need to fill that value of that column for me (and increment every time I insert a new one)?

Thank you.

Yes, absolutely possible. Just make this column a unique key (no primary key) and declare it with a special feature: "Identity" for SQL Server and "AUTO_INCREMENT" for MySQL (see examples below). And the other column can be the primary key.

The table on the MySQL database can be declared like this:

  create table 'meteable' (`name 'VARARA (50 ) No tap, `My_autoincrement_column` INTEGER (11) faucet AUTENCCimment, primary (` name`), unique key 'my_autoincorder_quelum' (`my_autoincermment_quelum`));  

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -