• 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

     


     

  • 相关阅读:
    HTML5存储
    HTML5全局属性和事件
    HTML5媒体(音频/视频)
    HTML5标签canvas制作动画
    HTML5标签canvas图像处理
    开发kendo-ui弹窗组件
    HTML5标签canvas制作平面图
    javascript匿名函数
    Javascript富文本编辑器
    快速排序算法(python版本)
  • 原文地址:https://www.cnblogs.com/toughhou/p/3778791.html
Copyright © 2020-2023  润新知