Obtain virtual column formula with SQL

oraclequeryvirtual-columns

We want to update the condition of a virtual column and to minimize error posibilites we want to extract the exact function working today to add new parameters to take into account.

I've firstly test with desc tablename but doesn't work, only shows column types.

Best Answer

This information can be found in the DATA_DEFAULT column of [DBA|ALL|USER]_TAB_COLUMNS.

Example:

SQL>  create table t1(c1 number, c2 number generated always as (abs(ceil(c1)*2)) virtual);

Table created.

SQL> select column_name, data_default from user_tab_columns where table_name = 'T1';

COLUMN_NAM DATA_DEFAULT
---------- --------------------
C1
C2         ABS(CEIL("C1")*2)