Oracle数据库备份,导入,导出

cmd.exe 连接数据库
sqlplus test/test@//127.0.0.1:1521/orcl

 

【数据导出】
导出orcl中所有的表空间
exp test/test@orcl file=h:\test.dmp log=h:\test.log buffer=8192000 full=y
注意:在运行中打cmd,进入后直接使用exp或imp命令。不要在sql下使用exp或imp命令

导出system数据库中指定的表空间
exp system/manager@orcl file=d:\daochu.dmp log=d:\daochu.log owner=(system,sys)

3. 导出数据库中制定的表数据
exp system/manager@orcl file=d:\daochu.dmp log=d:\daochu.log tables=(table1,table2)

导出数据库中table1中字段field1以“00”开头的数据
exp system/manager@orcl file=d:\daochu.dmp tables=(table1)query=" where filed1 like '00%'"
注:如果要压缩,则在最后面加上compress=y即可

【数据导入】
将D:\daochu.dmp 中的数据导入 orcl数据库中。
imp system/manager@orcl file=d:\daochu.dmp log=d:\daochu.log 
注:如果有的表已经存在,会提示报错,这个时候,在后面加上ignore=y,即已存在的表不导入

将d:\daochu.dmp中的表table1 导入
imp system/manager@orcl file=d:\daochu.dmp tables=(table1)
注:导入导出时,有时候会出现权限不足的情况

3.按用户导入

​ imp qyaqdc/qyaqdc@orcl fromuser=qyaqdc touser=qyaqdc file=F:\qyitsm20220420.dmp

这时,需要登录plus进行授权,首先登录管理员账号,然后:
GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,
DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,
DBA,CONNECT,RESOURCE,CREATE SESSION TO 用户名字

posted @ 2022-04-21 10:11  看看反馈  阅读(67)  评论(0)    收藏  举报