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

     


     

  • 相关阅读:
    无密码登录Linux
    php生成压缩包
    验证数字的正则表达式集
    初识MEF
    实现Linq.Distinct方法
    《Windows Internal》(2)
    《Windows Internals》(1)
    使用MEF宿主在一个应用程序上
    mysql错误记录集合
    python基本知识之数据类型
  • 原文地址:https://www.cnblogs.com/toughhou/p/3778791.html
Copyright © 2011-2022 走看看