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..


Oracle SQL_Null Related functions-3_NULLIF

Hi Aliens, Today, we will talk about another Null Related Function, NULLIF. You can read my notes on NVL, NVL2 […]


SQL – WHERE clause

Hi DBgeek Army, Welcome back to the world of Oracle! Where clause helps to select desired rows or helps to […]


Comment in SQL and PL-SQL

Hi DBgeek Army, Welcome back to the world of Oracle! Comments are very important aspects of our code. No matter […]

Leave a Reply

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