Technology ->
Database
2020-12-07 03:13:23
Table virtual column
1903
Introduction to Oracle Database Oracle Tables and Data definition Modifying data Oracle Query and Filter Oracle data types Joining tables Oracle Operators Grouping data Constraints
A virtual column is a table column whose values are calculated automatically using other column values, or another deterministic expression.
Here is the syntax of a virtual column:
column_name [data_type] [GENERATED ALWAYS] AS (expression) [VIRTUAL]
In this syntax:
- First, specify the name ( column_name) of the virtual column.
- Second, specify the virtual column’s data type. If you omit the data type, the virtual column will take the data type of the result of the expression.
- Third, specify an expression in parentheses after the AS keyword. The values of the virtual column will derive from the expression.
- Note that the GENERATED ALWAYS and VIRTUAL keywords are for clarity only.
This statement shows how to define a virtual column in the CREATE TABLE statement:
CREATE TABLE table_name ( ..., virtual_column_name AS (expression) );
And this statement illustrates how to add a virtual column to an existing table using the ALTER TABLE statement:
ALTER TABLE table_name ADD ( virtual_column_name AS (expression) );
Session is expired,Please login .