oracle 12c 新特性之不可见字段
? ? ? ?在Oracle 11g R1中,Oracle以不可見索引和虛擬字段的形式引入了一些不錯(cuò)的增強(qiáng)特性。繼承前者并發(fā)揚(yáng)光大,Oracle 12c 中引入了不可見字段思想。在之前的版本中,為了隱藏重要的數(shù)據(jù)字段以避免在通用查詢中顯示,我們往往會(huì)創(chuàng)建一個(gè)視圖來隱藏所需信息或應(yīng)用某些安全條件。
在12c中,你可以在表中創(chuàng)建不可見字段。當(dāng)一個(gè)字段定義為不可見時(shí),這一字段就默認(rèn)不會(huì)出現(xiàn)在通用查詢中,除非在SQL語(yǔ)句或條件中有顯式的提及這一字段,或是在表定義中有DESCRIBED。要添加或是修改一個(gè)不可見字段是非常容易的,反之亦然。
實(shí)驗(yàn):
1. 創(chuàng)建一個(gè)表,指定passwd為不可見字段
SQL>create table invisible_t(id int,name varchar2(20),passwd varchar2(20) invisible);
2. 向表中插入數(shù)據(jù)
SQL>insert into invisible_t values(1,'andy',1);
ERROR at line 1:
ORA-00913: too many values
SQL> insert into invisible_t(id,name,passwd) values(1,'andy',1);
1 row created.
SQL> insert into invisible_t(id,name) values(2,'andy02');
1 row created.
3. 查詢情況
SQL> select * from invisible_t;
ID NAME
---------- --------------------
1 andy
2 andy02
SQL> select id,name from invisible_t;
ID NAME
---------- --------------------
1 andy
2 andy02
SQL> select id,name,passwd from invisible_t;
ID NAME?PASSWD
---------- -------------------- --------------------
1 andy?1
2 andy02
4.修改字段為可見字段或不可見字段
SQL> alter table invisible_t modify(passwd visible);
Table altered.
SQL> select * from invisible_t;
ID NAME?PASSWD
---------- -------------------- --------------------
1 andy?1
2 andy02
SQL> alter table invisible_t modify(passwd invisible);
Table altered.
SQL> select * from invisible_t;
ID NAME
---------- --------------------
1 andy
2 andy02
-- 創(chuàng)建時(shí)未指定為不可見字段,若之后想修改為不可見字段,也可以。
SQL> ?alter table invisible_t modify(name invisible);
Table altered.
SQL> alter table invisible_t modify(name visible);
Table altered.
轉(zhuǎn)載于:https://www.cnblogs.com/andy6/p/6819716.html
總結(jié)
以上是生活随笔為你收集整理的oracle 12c 新特性之不可见字段的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: mysql怎样转换数据类型
- 下一篇: 浅析AntdV Upload组件cust