Oracle Database 12c supports invisible columns, which implies that the visibility of a column. A column marked invisible does not appear in the following operations:
SELECT * FROM queries on the table
SQL* Plus DESCRIBE command
Local records of %ROWTYPE
Oracle Call Interface (OCI) description
A column can be made invisible by specifying the INVISIBLE clause against the column. Columns of all types (except user-defined types), including virtual columns, can be marked invisible, provided the tables are not temporary tables, external tables, or clustered ones. An invisible column can be explicitly selected by the SELECT statement. Similarly, the INSERT statement will not insert values in an invisible column unless explicitly specified.
Furthermore, a table can be partitioned based on an invisible column. A column retains its nullity feature even after it is made invisible. An invisible column can be made visible, but the ordering of the column in the table may change.
In the following script, the column NICKNAME is set as invisible in the table t_inv_col:
/*Create a table to demonstrate invisible columns*/
CREATE TABLE t_inv_col
(id NUMBER,
name VARCHAR2(30),
nickname VARCHAR2 (10) INVISIBLE,
dob DATE
)
/
The information about the invisible columns can be found in user_tab_cols. Note that the invisible column is marked as hidden:
/*Query the USER_TAB_COLS for meta data information*/
SELECT column_id,
column_name,
hidden_column
FROM user_tab_cols
WHERE table_name = 'T_INV_COL'
ORDER BY column_id
/
COLUMN_ID COLUMN_NAME HID
---------- ------------ ---
1 ID NO
2 NAME NO
3 DOB NO
NICKNAME YES
Hidden columns are different from invisible columns. Invisible columns can be made visible and vice versa, but hidden columns cannot be made visible.
If we try to make the NICKNAME visible and NAME invisible, observe the change in column ordering:
/*Script to change visibility of NICKNAME column*/
ALTER TABLE t_inv_col MODIFY nickname VISIBLE
/
/*Script to change visibility of NAME column*/
ALTER TABLE t_inv_col MODIFY name INVISIBLE
/
/*Query the USER_TAB_COLS for metadata information*/
SELECT column_id,
column_name,
hidden_column
FROM user_tab_cols
WHERE table_name = 'T_INV_COL'
ORDER BY column_id
/
COLUMN_ID COLUMN_NAME HID
---------- ------------ ---
1 ID NO
2 DOB NO
3 NICKNAME NO
NAME YES
Regards,
Chandrasekar S
No comments:
Post a Comment