While designing a table my colleague here says that I should avoid identity column as it is specific to SQL Server and MS Access, But I differ with his views as it makes my codi
Do not use identity column unless you're fully aware of its pitfalls and has no valid reason to use SEQUENCE or an emulated sequence generator.
Sequences are much more flexible and do not have the disadvantages/restrictions that Identity columns have.
From http://www.jumpingbean.co.za/blogs/mark/identity_autoincrement_fields_and_database_sequences :
The pain with auto-incrementing
Copying over data while preserving identity value
Auto-incrementing keys can become a pain when you need to copy whole tabels and preserve the primary key value. Trying to insert directly into an identity column will result in a error being raised. Typically the vendor provides some statements that allow you to temporarily drop the constraint so you can insert existing values. In MSSQL you can issue the command
"SET IDENTITY_INSERT products ON".
Other vendors will require you to drop the constraint and then re-enable it.
More pain- how to retrieve value of newly inserted rows?
In addition the server usually provides different ways to retrieve the identity column value for a newly inserted row. For MySQL this is the LAST_INSERT_ID() function and for MSSQL it is @@identity eg select @@identity.
MS SQL Server 2011 will support SEQUENCE.
If you use a RDBMS server that doesn't support SEQUENCE (like MSSQL pre-2011 or MySQL), there are two alternatives: