[Oracle] 锁表情况下使用exp和expdp导出


本文总阅读量

1、共享锁

lock table test in share mode;
exp和expdp均可正常导出

1
2
3
4
5
6
7
8
9
exp test/Test1234 file=/tmp/test2.dmp  tables=test
Export: Release 11.2.0.4.0 - Production on Tue Jun 4 15:57:35 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table TEST 3 rows exported
Export terminated successfully without warnings.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
[oracle@dax-mysql-slave tmp]$ expdp test/Test1234 dumpfile=expdp5.test directory=exp_data_dir tables=test
Export: Release 11.2.0.4.0 - Production on Tue Jun 4 15:59:45 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "TEST"."SYS_EXPORT_TABLE_01": test/******** dumpfile=expdp5.test directory=exp_data_dir tables=test
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
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
. . exported "TEST"."TEST" 5.031 KB 3 rows
Master table "TEST"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for TEST.SYS_EXPORT_TABLE_01 is:
/tmp/backup/expdp5.test
Job "TEST"."SYS_EXPORT_TABLE_01" successfully completed at Tue Jun 4 15:59:49 2019 elapsed 0 00:00:03

2、排他锁

1
2
3
15:58:19 TEST@ boston> lock table test in exclusive mode;
Table(s) Locked.
Elapsed: 00:00:00.00

exp可正常导出

1
2
3
4
5
6
7
8
9
[oracle@dax-mysql-slave tmp]$ exp test/Test1234 file=/tmp/test4.dmp  tables=test
Export: Release 11.2.0.4.0 - Production on Tue Jun 4 16:00:51 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table TEST 3 rows exported
Export terminated successfully without warnings.

expdp导出进程被锁,直到排它锁被释放

1
2
3
4
5
6
7
8
9
10
11
12
13
[oracle@dax-mysql-slave tmp]$ expdp test/Test1234 dumpfile=expdp6.test directory=exp_data_dir tables=test
Export: Release 11.2.0.4.0 - Production on Tue Jun 4 16:01:30 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "TEST"."SYS_EXPORT_TABLE_01": test/******** dumpfile=expdp6.test directory=exp_data_dir tables=test
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
Processing object type TABLE_EXPORT/TABLE/INDEX/INDEX
Processing object type TABLE_EXPORT/TABLE/INDEX/STATISTICS/INDEX_STATISTICS
Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS

下面设置当然用户下的表空间为只读

1
2
3
4
5
16:03:04 TEST@ boston> select default_tablespace from user_users;
DEFAULT_TABLESPACE
------------------------------
USERS
16:03:04 TEST@ boston> alter tablespace users read only;

exp导出正常,expdp报错

1
2
3
4
5
6
7
8
9
[oracle@dax-mysql-slave tmp]$ exp test/Test1234 file=/tmp/test4.dmp  tables=test
Export: Release 11.2.0.4.0 - Production on Tue Jun 4 16:04:37 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Export done in ZHS16GBK character set and AL16UTF16 NCHAR character set
About to export specified tables via Conventional Path ...
. . exporting table TEST 3 rows exported
Export terminated successfully without warnings.
1
2
3
4
5
6
7
8
9
10
[oracle@dax-mysql-slave tmp]$ expdp test/Test1234 dumpfile=expdp7.test directory=exp_data_dir tables=test
Export: Release 11.2.0.4.0 - Production on Tue Jun 4 16:04:42 2019
Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
ORA-31626: job does not exist
ORA-31633: unable to create master table "TEST.SYS_EXPORT_TABLE_05"
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT", line 1038
ORA-01647: tablespace 'USERS' is read-only, cannot allocate space in it
目录
  1. 1. 1、共享锁
  2. 2. 2、排他锁

Proudly powered by Hexo and Theme by Lap
本站访客数人次
© 2020 zeven0707's blog