12C新特性:不可见字段

1、创建表

不可见字段的关键字为invisible,其中password为不可见字段。

SQL> CREATE TABLE t_whs_invisible
  2  (ID number, username varchar2(10),password varchar2(20) invisible);

Table created.

2、插入数据

SQL> insert into t_whs_invisible values(1,'test','test123');
insert into t_whs_invisible values(1,'test','test123')
            *
ERROR at line 1:
ORA-00913: too many values

插入数据报错,不可见字段需要明确指定字段名才能insert,如下:

SQL> insert into t_whs_invisible(ID,username,password) values(1,'test','test123');

1 row created.

SQL> commit;

Commit complete.

3、查询

查询的时候也有明确指定列名才能查看的到

SQL> select * from t_whs_invisible;

        ID USERNAME
---------- ------------------------------
         1 test

SQL> set linesize 200
SQL> select ID,username,password from t_whs_invisible;

        ID USERNAME                       PASSWORD
---------- ------------------------------ ------------------------------------------------------------
         1 test                           test123

desc查看表结构是没有这个字段的

SQL> desc t_whs_invisible
 Name                    Null?    Type
 ----------------------- -------- ----------------
 ID                               NUMBER
 USERNAME                         VARCHAR2(10)

只有查看视图才能看到

SQL>  select table_name,column_name from dba_tab_columns where table_name='T_WHS_INVISIBLE';

TABLE_NAME      COLUMN_NAME
--------------- ------------------------------
T_WHS_INVISIBLE ID
T_WHS_INVISIBLE USERNAME
T_WHS_INVISIBLE PASSWORD

Related Posts