How to create virtual column in oracle database table?
What is the advantage of a virtual column?
meda Changed status to publish 07/03/2022
Yes, it is possible to create an Oracle table having virtual columns on Oracle 12c.But the virtual columns can only be created from the existing columns of the same table. And these columns will be not stored on disk and are calculated when we run SQL queries.
Example:
SQL> conn mereba/mereba@to_primary Connected. SQL> SQL> create table emp_sal( 2 emp_id number 3 ,salary number 4 ,JOBTitle as ( 5 case when salary <= 2000 then 'PROFESSIONAL' 6 when salary between 4000 and 7000 then 'MANAGER' 7 when salary >7000 then 'DIRECTOR' 8 end) 9 ); Table created. SQL> insert into emp_sal (emp_id,salary) values (005,5000); 1 row created. SQL> select * from emp_sal; EMP_ID SALARY JOBTITLE ---------- ---------- ------------ 5 5000 MANAGER
meda Edited answer 21/02/2022