博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Oracle 11g 新特性 -- 只读表(read-only table)说明
阅读量:4212 次
发布时间:2019-05-26

本文共 1585 字,大约阅读时间需要 5 分钟。

一.Read only table说明

 

     在Oracle 11g之前,如果我们想要对一个表设置为只读的,可以通过授予某些用户select 权限。 但是对于表的所有者来说,还是读写的。

 

    在Oracle 11g中,我们可以直接对表的读写权限进行设置:

        ALTER TABLE table_name READ ONLY;

        ALTER TABLE table_name READ WRITE;

 

二.示例

 

--创建表

SQL> create table dave as select * fromdba_objects;

 

Table created.

 

--设置为只读:

SQL> alter table dave read only;

Table altered.

 

--查看表状态:

SQL> select table_name,status,read_onlyfrom dba_tables where table_name='DAVE';

 

TABLE_NAME                     STATUS   REA

------------------------------ -------- ---

DAVE                           VALID    YES

--这里显示是只读的。

 

--对Dave表进行DML操作:

SQL> insert into dave select * fromdave;

insert into dave select * from dave

           *

ERROR at line 1:

ORA-12081: update operation not allowed ontable "SYS"."DAVE"

 

SQL> update dave set object_id=88;

update dave set object_id=88

      *

ERROR at line 1:

ORA-12081: update operation not allowed ontable "SYS"."DAVE"

 

 

SQL> delete from dave;

delete from dave

           *

ERROR at line 1:

ORA-12081: update operation not allowed ontable "SYS"."DAVE"

 

SQL> truncate table dave;

truncate table dave

               *

ERROR at line 1:

ORA-12081: update operation not allowed ontable "SYS"."DAVE"

 

 

SQL> alter table dave add(namevarchar(20));

alter table dave add(name varchar(20))

*

ERROR at line 1:

ORA-12081: update operation not allowed ontable "SYS"."DAVE"

 

 

--虽然表示只读的,但是我们对表进行与索引相关的操作,因为索引修改的是数据字典,和表不相关。

SQL> create index idx_id on dave(object_id);

 

Index created.

 

SQL> drop index idx_id;

 

Index dropped.

 

--将表改成读写:

SQL> altertable dave read write;

 

Table altered.

 

SQL> droptable dave;

 

Table dropped.

 

 

 

 

版权所有,文章允许转载,但必须以链接方式注明源地址,否则追究法律责任!

QQ:492913789

Email:ahdba@qq.com

Blog:  

Weibo:    

Twitter: 

Facebook:

Linkedin:

你可能感兴趣的文章
test-definitions/blob/master/auto-test/iostat/iostat.sh
查看>>
test-definitions/blob/master/auto-test/kernel-compilation/kernel-compilation.sh
查看>>
内核ACPI函数API之acpi_platform_fill_resource
查看>>
内核ACPI函数API之acpi_create_platform_device
查看>>
ceph网络通信架构
查看>>
内核ACPI函数API之acpi_scan_add_handler
查看>>
内核ACPI函数API之acpi_bind_one和acpi_unbind_one
查看>>
bios 为硬盘中的grub生成入口
查看>>
kernel解析SRAT 表的个数限制是NR_NODE_MEMBLKS
查看>>
内核ACPI函数API之acpi_execute_simple_method
查看>>
内核ACPI函数API之acpi_bus_get_status
查看>>
内核ACPI函数API之acpi_get_first_physical_node
查看>>
内核ACPI函数API之acpi_os_read_memory
查看>>
内核ACPI函数API之acpi_notifier_call_chain
查看>>
内核ACPI函数API之acpi_bus_generate_netlink_event
查看>>
内核ACPI函数API之acpi_os_read_pci_configuration
查看>>
内核ACPI函数API之acpi_os_execute
查看>>
内核ACPI函数API之acpi_is_root_bridge
查看>>
ceph中的存储用到的类
查看>>
内核ACPI函数API之acpi_pci_find_root
查看>>