The code adds one to the Current Value, and puts the result into a new row. This code finds the highest value for a column: the "Current Value" of the sequence. INSERT INTO Table1 VALUES (Current_Value + 1. SELECT MAX(identity_column) INTO Current_Value FROM Table1 The Old Way: SELECT MAX and Key Tablesīefore DB2 version 7.2, Oracle6, and SQL Server 6.0, users coded their own sequence generators with "SELECT MAX" or with "Key Tables." SELECT MAX code looks like this: I'll use a convention for some of the specialized vocabulary: a "Special Term" will be in quotes the first time it appears and will be capitalized if it's a noun. Let's look at the compromises and efficiencies of sequences in Oracle / DB2 SEQUENCE objects and DB2 / SQL Server IDENTITY columns. That's okay, because the main use of sequences - getting short unique numbers for primary keys - is more efficient if some compromises happen. My Oxford Concise Dictionary says a sequence is a "set of things belonging next to each other on some principle of order" or a "series without gaps." Yet IBM DB2®, Microsoft SQL Server 2000, and Oracle9i can make sequences with both disorder and gaps.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |