January 2007 Technical Tip – Oracle: Sequence number in a table column
The example contained in this article shows how to generate a sequence number for use as an entry in a table column when using Oracle. The sequence object is used to maintain a sequence number. This object can then be inserted into a table using the nextval function. You will likely need a separate sequence object for each table requiring a sequence number.
Here is the result of the last two instructions of this script (using Oracle 10g Express Edition).
In addition to the nextval function, there is also a currval function which can be used to retrieve the value of the most recent insert. This function is often used when you want to insert rows with the same number into another table.
We hope you will consider Caliber Data Training when you are in need of high quality database training including SQL.