Monday, April 15, 2013

Virtual Columns in 11g

virtual columns in 11g

creating a virtual column:

We will begin by creating a simple table with a single virtual column, as follows.

SQL> CREATE TABLE t
  2  ( n1 INT
  3  , n2 INT
  4  , n3 INT GENERATED ALWAYS AS (n1 + n2) VIRTUAL
  5  );

Table created.

SQL> INSERT INTO t (n1, n2) VALUES (10, 20);

1 row created.
.
SQL> SELECT * FROM t;

        N1         N2         N3
---------- ---------- ----------
        10         20         30

1 row selected.
Our expression is evaluated at runtime and gives the output we see above.

source code

The source code for the examples in this article can be downloaded from here.

No comments:

Post a Comment

Thank You For Comment