Oracle Virtual Column


admin DataBase, Oracle ,

Hello guys,
Hope you are doing well. Today, we will talk about the Oracle Virtual Column.
I will try to cover all important aspects in this blog.

What is a Virtual Column?

A virtual column is same as a normal column but when this column is queried, its values are derived based on the other columns rather than being stored on disc.

Here is the syntax to add a virtual column to a table.

column_name [datatype] [GENERATED ALWAYS] AS (expression) [VIRTUAL]

If the datatype is omitted, it is determined based on the result of the expression. The GENERATED ALWAYS and VIRTUAL keywords are provided for clarity only. We can omit these keywords as well.

The script below creates a table with a few columns including a virtual column. Email Domain is the virtual column and it is populated based on the Email column.

Let’s query the table and see all the columns and the data in the Employees table.

The expression used to generate the virtual column is listed in the DATA_DEFAULT column of the below listed views.


Limitations of Virtual Column?

  • Virtual Column can only be used with Oracle 11g and later versions.
  • Virtual Columns cannot reference other virtual columns value. In this case below snippet code is invalid.

  • Values cannot be inserted into the Virtaul Column. It is populated automatically based on the other columns as per the expressions.
  • It can only refer to columns defined in the same table.
  • Virtual columns can be referenced in the WHERE clause of updates and deletes, but they cannot be manipulated by DML.

If you have any questions please comment below or write me an email.
If you like this blog, do share with your friends and colleagues on your social media.
For more updates join my facebook group and do like my facebook page.

Thank you,
Kapil Kumar

Sharing is caring!

You May Also Like..

Pseudocolumn - ORA_ROWSCN

Pseudocolumn – ORA_ROWSCN

Hi DBgeek Army, Welcome back to the world of Oracle! Today, we will talk about Pseudocolumn. Oh, wait. Have you […]


SQL – MERGE Statement

Hi Devs, As we have already learned INSERT INTO and UPDATE statement, our next very important statement is MERGE. Merge […]


SQL – UPDATE Statement part-2

Hi Geeks, In previous blog on UPDATE statement, we learnt, how can we update a column value with a string […]

Leave a Reply

Your email address will not be published. Required fields are marked *