oracle 表空間和表 read only遷移後不再read only
DB : 11.2.0.3.0
1.將tablespace read only , 不允許再對錶進行update、insert操作,測試dmp到另一個使用者、表空間後是否可以update、insert
2.將table read only, 不允許再對錶進行update、insert操作, 測試dmp表到另一個使用者、表空間後是否可以update、insert
1.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/orcl/system01.dbf
/u01/app/oracle/oradata/orcl/sysaux01.dbf
/u01/app/oracle/oradata/orcl/undotbs01.dbf
/u01/app/oracle/oradata/orcl/users01.dbf
/u01/app/oracle/oradata/orcl/yoon01.dbf
SQL> create tablespace yoon datafile '/u01/app/oracle/oradata/orcl/yoon01.dbf' size 100m;
Tablespace created.
SQL> create user yoon identified by yoon default tablespace yoon ;
User created.
SQL> grant dba to yoon;
Grant succeeded.
SQL>show user
USER is "YOON"
SQL> create table yoon as select * from scott.emp;
Table created.
SQL> alter tablespace yoon read only;
Tablespace altered.
更新:
SQL> update yoon set empno=9999 where empno=7934;
update yoon set empno=9999 where empno=7934
*
ERROR at line 1:
ORA-00372: file 5 cannot be modified at this time
ORA-01110: data file 5: '/u01/app/oracle/oradata/orcl/yoon01.dbf'
插入:
SQL> insert into yoon select * from scott.emp;
insert into yoon select * from scott.emp
*
ERROR at line 1:
ORA-00372: file 5 cannot be modified at this time
ORA-01110: data file 5: '/u01/app/oracle/oradata/orcl/yoon01.dbf'
備份:
[oracle@db01 backup]$ expdp system/admin directory=data dumpfile=yoon.dmp logfile=yoon.log tables=yoon.yoon
Export: Release 11.2.0.3.0 - Production on Fri Oct 31 21:53:46 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_TABLE_01": system/******** directory=data dumpfile=yoon.dmp logfile=yoon.log tables=yoon.yoon
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "YOON"."YOON" 8.570 KB 14 rows
Master table "SYSTEM"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is:
/u01/backup/yoon.dmp
Job "SYSTEM"."SYS_EXPORT_TABLE_01" successfully completed at 21:54:02
[oracle@db01 backup]$ ls
yoon.dmp yoon.log
匯入至scott使用者:
[oracle@db01 backup]$ impdp system/admin directory=data dumpfile=yoon.dmp logfile=yoon_imp.log tables=yoon.yoon remap_schema=yoon:scott remap_tablespace=yoon:users
Import: Release 11.2.0.3.0 - Production on Fri Oct 31 21:55:43 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TABLE_01": system/******** directory=data dumpfile=yoon.dmp logfile=yoon_imp.log tables=yoon.yoon remap_schema=yoon:scott remap_tablespace=yoon:users
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."YOON" 8.570 KB 14 rows
Job "SYSTEM"."SYS_IMPORT_TABLE_01" successfully completed at 21:55:50
檢視scott使用者下表的狀態:
SQL> select owner,table_name,TABLESPACE_NAME,STATUS,TABLE_LOCK,READ_ONLY from dba_tables where table_name='YOON' and owner='SCOTT';
OWNER TABLE_NAME TABLESPACE_NAME STATUS TABLE_LO REA
---------- --------------- ------------------------------ -------- -------- ---
SCOTT YOON USERS VALID ENABLED NO
SQL> update yoon set empno=9999 where empno=7934;
1 row updated.
SQL> insert into yoon select * from emp;
14 rows created.
SQL> commit;
將表空間read only後,將表遷移至另一個使用者、表空間,可以進行update、insert操作。
2.
SQL> alter tablespace yoon read write;
Tablespace altered.
SQL> alter table yoon read only;
Table altered.
備份yoon表:
[oracle@db01 backup]$ expdp system/admin directory=data dumpfile=yoon.dmp logfile=yoon.log tables=yoon.yoon
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TABLE_01 is:
/u01/backup/yoon.dmp
Job "SYSTEM"."SYS_EXPORT_TABLE_01" successfully completed at 22:03:29
匯入yoon表至scott使用者:
[oracle@db01 backup]$ impdp system/admin directory=data dumpfile=yoon.dmp logfile=yoon_imp.log tables=yoon.yoon remap_schema=yoon:scott remap_tablespace=yoon:users
Import: Release 11.2.0.3.0 - Production on Fri Oct 31 22:04:44 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "SYSTEM"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "SYSTEM"."SYS_IMPORT_TABLE_01": system/******** directory=data dumpfile=yoon.dmp logfile=yoon_imp.log tables=yoon.yoon remap_schema=yoon:scott remap_tablespace=yoon:users
Processing object type TABLE_EXPORT/TABLE/TABLE
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "SCOTT"."YOON" 8.570 KB 14 rows
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
Job "SYSTEM"."SYS_IMPORT_TABLE_01" successfully completed at 22:04:49
檢視錶的狀態:
SQL> select owner,table_name,TABLESPACE_NAME,STATUS,TABLE_LOCK,READ_ONLY from dba_tables where table_name='YOON' and owner='SCOTT';
OWNER TABLE_NAME TABLESPACE STATUS TABLE_LO REA
---------- --------------- ---------- -------- -------- ---
SCOTT YOON USERS VALID ENABLED NO
SQL> update yoon set empno=9999 where empno=7934;
1 row updated.
SQL> insert into yoon select * from emp;
14 rows created.
SQL> commit;
將表設定read only,遷移至另一個使用者、表空間後,可以進行update、insert操作 。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/28939273/viewspace-1315848/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Oracle 11g 新特性:只讀表(Read-only)Oracle
- [20200309]expdp 與read only.txt
- 3.2.3 Opening a Database in Read-Only ModeDatabase
- CSS :read-only 選擇器CSS
- DG -- READ ONLY模式開啟物理Standby模式
- Oracle中表空間、表、索引的遷移Oracle索引
- Oracle 12cbigfile表空間物件遷移Oracle物件
- oracle 表移動表空間Oracle
- Oracle表移動表空間Oracle
- idea怎麼修改檔案的file is read-onlyIdea
- MySQL 遷移表空間,備份單表MySql
- 005-blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]BloCORBIndexdeleteAPI
- remount of /system failed: Read-only file system原因及解決REMAI
- table/index/LOBINDEX遷移表空間Index
- [AlwaysOn2017] AlwaysOn的DMV和DMF - Sys.availability_read_only_routing_listsAI
- oracle ocp 19c考題,科目082考試題(21)-read-only tableOracle
- 執行新增和修改操作報錯connection is read-only. Queries leading to data modification are not allowed
- oracle 表空間Oracle
- Oracle表空間Oracle
- MySQL 中出現報錯提示: ‘Variable ‘XXX‘ is a read only variable‘的解決方法MySql
- Mysql的read_only 只讀屬性說明 (運維筆記)MySql運維筆記
- 【報錯】elasticsearch 報錯blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]ElasticsearchBloCORBIndexdeleteAPI
- 對Oracle分割槽表進行表空間遷移並處理ORA-14511問題Oracle
- mysql共享表空間擴容,收縮,遷移MySql
- MySQL報錯Table 'plugin' is read only [ERROR] Can't open the mysql.plugin table.MySqlPluginError
- 對Mysql中的read_only 只讀屬性做簡要說明MySql
- oracle temp 表空間Oracle
- 增加oracle表空間Oracle
- oracle建立臨時表空間和資料表空間以及刪除Oracle
- AndroidStudio之自定義輸出包名報錯 Cannot set the value of read-only property 'outputFile' forAndroid
- MySQL案例04:Cause: java.sql.SQLException: Could not retrieve transaction read-only status from serverMySqlJavaExceptionServer
- Oracle建立表空間和使用者Oracle
- oracle 建立表空間和使用者Oracle
- oracle表空間的整理Oracle
- Oracle 批量建表空間Oracle
- Oracle清理SYSAUX表空間OracleUX
- 達夢(DM)資料庫的表空間建立和遷移維護資料庫
- Oracle新建使用者、表空間、表Oracle
- 用傳輸表空間跨平臺遷移資料