User SCOTT wants to export his objects using Oracle Data Pump and executes the following command:
$ expdp scott/tiger
directory = EXPORT_DIR
dumpfile = scott.dmp
include = table
include = view:"like '%DEPARTMENTS%'"
content = DATA_ONLY
Which task would the command accomplish?
A. Oracle Data Pump would export only the data of all of the tables and views.
B. Oracle Data Pump would export all of the table structures along with data and all the views.
C. Oracle Data Pump would export the table data and the view definitions where the view name contains a string named DEPARTMEN
D. Oracle Data Pump would export the table data and the view definitions with data where view name contains a string named DEPAR
E. Oracle Data Pump would export all of the table structures and the view definitions with data where view name contains
DEPARTMENTS.
Answer: C
先上结论:加了data_only是不会导出普通视图的,物化视图和表一样,但是不会把视图定义导出,数据会导出,再导入会报错。
这里个人觉得选A。
DATA_ONLY
unloads only table row data; no database object definitions are unloaded.
oracle数据泵备份(Expdp命令)
ORA-39006,ORA-39213,ORA-06512,ORA-01114,ORA-39065EXPDP报错问题处理
https://www.linuxidc.com/Linux/2013-05/83774.htm
使用命令行运行expdp会出现错误,
Some operating systems require that quotation marks on the command line be preceded by an escape character. The following are examples of how case-sensitivity can be preserved in the different Export modes.
-
In command-line mode:
TABLES='"Emp"'
-
In parameter file mode:
TABLES='"Emp"'
加上转义符后正确
grant connect to scott; grant resource to scott;
grant create MATERIALIZED VIEW to scott; grant create view to scott; grant exp_full_database to scott; grant read, write on directory DATA_PUMP_DIR to scott; --- create table emp1 as select * from scott.emp; create view DEPARTMENTS as select * from scott.emp1; --DATA_ONLY模式导出 expdp scott/tiger directory = DATA_PUMP_DIR dumpfile = scott.dmp include = table:"like '\%EMP1\%'" include = view:"like '\%DEPARTMENTS\%'" content = DATA_ONLY --
Total estimation using BLOCKS method: 64 KB
. . exported "SCOTT"."EMP1" 8.570 KB 14 rows
ORA-39168: Object path VIEW was not found.
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SCOTT.SYS_EXPORT_SCHEMA_01 is:
/home/oracle/app/oracle/admin/orcl/dpdump/scott.dmp
Job "SCOTT"."SYS_EXPORT_SCHEMA_01" completed with 1 error(s) at 00:23:37
--无DATA_ONLY
expdp scott/tiger directory = DATA_PUMP_DIR dumpfile = scott1.dmp include = table:"like '\%EMP1\%'",view:"like '\%DEPARTMENTS\%'"
Processing object type SCHEMA_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type SCHEMA_EXPORT/TABLE/TABLE
Processing object type SCHEMA_EXPORT/VIEW/VIEW
. . exported "SCOTT"."EMP1" 8.570 KB 14 rows
Master table "SCOTT"."SYS_EXPORT_SCHEMA_01" successfully loaded/unloaded
--
drop view DEPARTMENTS;这种情况下导入并无视图的定义
truncate table emp1; --1 impdp scott/tiger directory = DATA_PUMP_DIR dumpfile = scott.dmp --这里数据导入了,但是视图定义并未导入 --2drop table emp1; impdp scott/tiger directory = DATA_PUMP_DIR dumpfile = scott1.dmp --这里视图定义导入了,表和数据都导入了
结论:加了data_only是不会导出普通视图的
物化视图和表情况一样。