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


Parentheses in SQL

Hey time travellers, Though Parentheses are used pretty much everywhere in SQL but in this blog, we will talk about […]

Logical Conditions

Oracle – Logical Conditions

Hey time travellers, In this article, we will be discussing Logical Conditions. It is a very important aspect of SQL. […]


Oracle – IN Condition

Hey people, In this Oracle tutorial, we will learn how to use IN condition in SQL. IN condition is used […]

Leave a Reply

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