I am getting so many mails on what is the equivalent of Oracle Sequence in SQL Server?
There is nothing like equivalent of Oracle Sequence in SQL Server. At the same time IDENTITY can not be compared with Sequence in Oracle. All though there is a feature called IDENTITY to produce unique numbers.
Both are very unique and useful features in each of the databases.
Oracle Sequence Advantages:
1) Standalone object any one can use it for any column.
2) This is not tightly coupled with any column so one can easily drop this object.
3) One can easily insert the data into Sequence related column.
4) You can use the same sequence to populate multiple columns in the same table.
5) You need to explicitly use Sequence Name during inserts.
SQL Server IDENTITY Advantages:
1) IDENTITY is a property which is tightly coupled with column in a table.
2) This is tightly coupled with column so you can’t drop this property. The only way to drop IDENTITY property is to drop the column itself.
3) To insert the data into IDENTITY column you need to set a flag.
4) You can have only one column per table with the IDENTITY property.
5) You need to skip the IDENTITY column during inserts.
Keep watching for more information on IDENTITY in SQL Server.
Tuesday, April 28, 2009
Oracle Sequence Vs IDENTITY in SQL Server
Labels:
DotNetVJ,
Vijaya Kadiyala
Subscribe to:
Post Comments (Atom)
7 comments:
Good Comparision. Good way to explain about the features of the databases.
Thanks for this article.It explains the comparisons very well.
Oracle sequence is not transactional. It's value is not restored after transaction rollback.
You can also use triggers with a sequence to achieve virtually the same kind of functionality as an identity.
Frankly, I don't see any advantage with identities. I think they're stupid. Sequences are far more flexible.
thanks for sharing the info.
ithout making this into a religious discussion, a major one benefit of identity for example is concurrency control. Incorporating non-composite keys into data models is so much easier than having to deal with sequences in code.
Cheers,
Neel
How do find out, which column is using a sequence (identity)?
Post a Comment