zoukankan      html  css  js  c++  java
  • Oracle设置表只读-alter table xxx read only

    11g以前,当需要设置一个表只读时,我们通过赋予某些用户select权限。但对于表的owner来说,还是可以读写的。
     

    从Oracle 11g开始,我们可以通过一下命令设置表只读或可读可写:
    alter table tab1 read only;
    alter table tab1 read write;

     

    SQL> create table t1 (t number);

    Table created

    --设置表为只读
    SQL> alter table t1 read only;

    Table altered

     

    --DML操作,insert/update/delete都不允许
    SQL> insert into t1 values (1);

    insert into t1 values (1)

    ORA-12081: update operation not allowed on table "TOUGH"."T1"

     

    SQL> update t1 set t=0;

    update t1 set t=0

    ORA-12081: update operation not allowed on table "TOUGH"."T1"

     

    SQL> delete from t1;

    delete from t1

    ORA-12081: update operation not allowed on table "TOUGH"."T1"

     

    --DDL操作,truncate不允许
    SQL> truncate table t1;

    truncate table t1

    ORA-12081: update operation not allowed on table "TOUGH"."T1"

     

    SQL> alter table t1 add (a number);

    alter table t1 add (a number)

    ORA-12081: update operation not allowed on table "TOUGH"."T1"


    --虽然表设置成了只读,但此处对表进行与索引相关操作,因为索引修改的是数据字典,和表不相关,所以可以进行
    SQL> create index t1_indx on t1(t);

    Index created

     


     

  • 相关阅读:
    Android存储数据方式(转)
    Android实现双进程守护 (转)
    Android DOM、SAX、Pull解析XML(转)
    TCP/IP和Socket的关系(转)
    Socket通信原理和实践
    [转]Android中Intent传递对象的两种方法(Serializable,Parcelable)
    内存堆和栈的区别
    hdu 1754 线段树
    hdu 1166 线段树
    zoj 3686 线段树
  • 原文地址:https://www.cnblogs.com/toughhou/p/3778791.html
Copyright © 2011-2022 走看看