Difference between revisions of "NEXTVAL"
From Lianjapedia
Yvonne.milne (Talk | contribs) m (1 revision: SQL) |
Yvonne.milne (Talk | contribs) |
||
Line 1: | Line 1: | ||
==Purpose== | ==Purpose== | ||
Return the next unique sequence number from the specified table | Return the next unique sequence number from the specified table | ||
− | |||
==Syntax== | ==Syntax== | ||
NEXTVAL | NEXTVAL | ||
− | |||
==See Also== | ==See Also== | ||
[[PSEUDO COLUMNS]], [[SQL INSERT|INSERT]], [[SQL SELECT|SELECT]], [[SQL UPDATE|UPDATE]] | [[PSEUDO COLUMNS]], [[SQL INSERT|INSERT]], [[SQL SELECT|SELECT]], [[SQL UPDATE|UPDATE]] | ||
− | |||
==Description== | ==Description== | ||
Line 15: | Line 12: | ||
The NEXTVAL Pseudo Column will return the next unique sequence number from the specified table. Sequence numbers can be used for primary and unique index keys. | The NEXTVAL Pseudo Column will return the next unique sequence number from the specified table. Sequence numbers can be used for primary and unique index keys. | ||
− | |||
==Example== | ==Example== | ||
Line 26: | Line 22: | ||
</code> | </code> | ||
− | |||
− | |||
− | |||
[[Category:Documentation]] | [[Category:Documentation]] | ||
[[Category:SQL]] | [[Category:SQL]] | ||
[[Category:Pseudo Columns]] | [[Category:Pseudo Columns]] |
Revision as of 13:24, 10 February 2012
Contents
Purpose
Return the next unique sequence number from the specified table
Syntax
NEXTVAL
See Also
PSEUDO COLUMNS, INSERT, SELECT, UPDATE
Description
A Pseudo Column behaves like a table column, but is not actually stored in the table. You can select from Pseudo Columns, but they cannot be updated. Pseudo Columns provide extra information about a SELECT row set.
The NEXTVAL Pseudo Column will return the next unique sequence number from the specified table. Sequence numbers can be used for primary and unique index keys.
Example
CREATE TABLE cust (acc_num INT , acc_name char(20)) INSERT INTO cust (acc_num, acc_name) VALUES (NEXTVAL, "Smith") INSERT INTO cust (acc_name) VALUES ("Brown") INSERT INTO cust (acc_num, acc_name) VALUES (CURRVAL+2, "Jones") SELECT * from cust