How to Use Pseudocolumns
A "pseudocolumn" is an expression that you can reference on an SQL statement. It is not a column that is stored on a table. Pseudocolumns have a variety of applications including hierarchical queries, row metadata and sequences. In this topic I will show you how sequence data can be obtained from pseudocolumns.
To learn how to use pseudocolumns, follow these steps:
- You'll need to download and install Oracle 12c. The instructions for the setup can be found in How to use sample schemas. Follow steps 1 through 4 in this topic before proceeding to the next step.
- Sequences are used in Oracle to facilitate the insert of new rows into database tables. In the HR schema, we have an employee sequence named
employees_seq. The current value of the sequence can be determined by executing this query:
The pseudocolumn I have referenced is
currval. You can also display the
nextvalpseudocolumn. Whenever you reference this column on an SQL statement the pseudocolumn will increment the sequence and return the new value.