How to backup view and some tables in oracle?

2019-07-18 09:41发布

问题:

I have an Oracle database. On the database There are three tables (a,b,c tables) and a view (union of a and b tables).

I want to backup of a dan b tables and also the view. I used this syntax exp user/psw file=backup.dmp tables=(a,b) ,but it doesnt backup the view,only the table. How can i include the view to be backed up?

回答1:

From Oracle 10g onward, expdp is standard export command and exp is deprecated.

expdp has include clause where in you can specify tables and views you want to export. Here is a sample command.

expdp scott/tiger@mydb schemas=MYSCHEMA
 include=TABLE:"IN ('A', 'B','C')",VIEW:"IN('my_view')"  
 directory=MY_DIR dumpfile=Exp_ABC_MyView.dmp logfile=expdpExp_ABC_MyView.log

Further you can export only object definitions or data or both as well. more examples in https://oracle-base.com/articles/10g/oracle-data-pump-10g



回答2:

You can not include a view to be backed up while using the "exp" utility. Oracle's expdp utility provides option to include views while exporting.



回答3:

Use imp commnad with this parameters

imp user/pass@service file=dumpfile.dmp log=logfile.log full=y rows=n  ignore=n grants=n indexes=n


标签: oracle dump