Oracle enables us to store expressions directly in the base tables themselves as virtual columns. These virtual columns are flexible than other alternatives.
Example:
create table sample(
s1 int,
s2 int,
s3 generated always as (s1*s2) virtual);
s3 generated always as (s1*s2) virtual);
s3 is automatically updated when s1 and s2 values are inserted into the table.
restrictions:
For two columns we cannot create virtual columns directly, we have to use functions to create multiple virtual columns in the table. While inserting we have to mention the column names beside table name as shown below:
insert into sample(s1,s2) values(10,20);
1 row inserted.
insert into sample values(10,20);
*
not enough values ---> error occured because the table having 3 columns. so we have to mention the column names beside the table name as shown in before example
No comments:
Post a Comment