Oracle Virtual Column

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

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.

  1. DBA_TAB_COLUMNS
  2. ALL_TAB_COLUMNS
  3. USER_TAB_COLUMNS

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

Hello guys, Hope you are doing fantastic being an Oracle professional. I wrote a blog on Oracle TABLESPACE. If you […]

Oracle-Tablespace

Hello guys, Hope you are doing well. Today, we will talk about Oracle Tablespace and I will try to cover […]

Oracle Set Operators

Hello guys, Hope you are doing well. Today, we will talk about Oracle Operators. An operator manipulates individual data items […]

2 Comments

  1. I just like the helpful info you provide in your articles. I’ll bookmark your weblog and take a look at again right here frequently. I’m moderately certain I’ll learn plenty of new stuff right right here! Good luck for the following!

Leave a Reply

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