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:

  1. 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.
  2. 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:
    Display current employee sequence value
    The pseudocolumn I have referenced is currval. You can also display the nextval pseudocolumn. Whenever you reference this column on an SQL statement the pseudocolumn will increment the sequence and return the new value.
Author: Stephen Withrow

Stephen has over 30 years of experience in training, development, and consulting in a variety of technology areas including Python, Java, C, C++, XML, JavaScript, Tomcat, JBoss, Oracle, and DB2. His background includes design and implementation of business solutions on client/server, Web, and enterprise platforms. Stephen has a degree in Computer Science and Physics from Florida State University.

About Webucator

Webucator provides instructor-led training to students throughout the US and Canada. We have trained over 90,000 students from over 16,000 organizations on technologies such as Microsoft ASP.NET, Microsoft Office, Azure, Windows, Java, Adobe, Python, SQL, JavaScript, Angular and much more. Check out our complete course catalog.