zoukankan      html  css  js  c++  java
  • oracle 12c 新特性之不可见字段

           在Oracle 11g R1中,Oracle以不可见索引和虚拟字段的形式引入了一些不错的增强特性。继承前者并发扬光大,Oracle 12c 中引入了不可见字段思想。在之前的版本中,为了隐藏重要的数据字段以避免在通用查询中显示,我们往往会创建一个视图来隐藏所需信息或应用某些安全条件。
       在12c中,你可以在表中创建不可见字段。当一个字段定义为不可见时,这一字段就默认不会出现在通用查询中,除非在SQL语句或条件中有显式的提及这一字段,或是在表定义中有DESCRIBED。要添加或是修改一个不可见字段是非常容易的,反之亦然。

    实验:
    1. 创建一个表,指定passwd为不可见字段
    SQL>create table invisible_t(id int,name varchar2(20),passwd varchar2(20) invisible);
    2. 向表中插入数据
    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
    -- 创建时未指定为不可见字段,若之后想修改为不可见字段,也可以。
    SQL>  alter table invisible_t modify(name invisible);

    Table altered.

    SQL> alter table invisible_t modify(name visible);

    Table altered.

  • 相关阅读:
    《Java程序设计》 第一周学习任务(2)
    《Java程序设计》 第一周学习任务(1)
    Git 提示fatal: remote origin already exists 解决办法
    写给小白的酸酸乳使用方法
    美國Tarrant County College
    硬盘数据恢复工具终身版
    安卓手机系统安装虚拟机
    linux网络基础
    Linux基础命令:read
    Linux shell基础
  • 原文地址:https://www.cnblogs.com/andy6/p/6819716.html
Copyright © 2011-2022 走看看