Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

standardized way of auto_increment

Tags:

sql

standards

Is there a standardized way I can create a table in SQL with a column (lets call it ID) that is auto incremental so that I can basicly use it in all databases?

(e.g. standardized in SQL-92) If so - how? If not, why? I think auto_increment is a very often used property so I thought it is very important to standardize it...

like image 305
Novellizator Avatar asked Oct 21 '22 16:10

Novellizator


1 Answers

Nope, sorry. There is AUTO_INCREMENT in MySQL, but e.g. in MS SQL this is called IDENTITY. Many things are not really standardized in SQL - and most are in the schema creating area.

It's a mess, but you can use stuff like e.g. Hibernate/NHibernate to try to use a single code base.

like image 135
Nux Avatar answered Nov 04 '22 00:11

Nux