oracle 数据库学习笔记
Giser-Yu
1、导入命令
imp Test/Test@ORCL file='D:\bdcdata\Test.DMP' log='D:\bdcdata\Test_in.log' full=y;
参数tables=(table1,table2)设置部分表导出/导入
2、导出命令
exp userid=scott/tiger@orcl file=D:\BACK01.dmp log=D:\BACK01.log
3、数据泵导入、导出操作
1.使用管理员身份登陆:
sqlplus username/password@SID as sysdba
2.创建路径:
create or replace directory cad as 'E:\oracle';
3.给用户授权
grant read,write on directory cad to username(指定用户)/public(所有用户);
grant read,write on directory cad to Test;
4.数据还原(在cmd窗口运行):
impdp username/password@ORCL directory=cad dumpfile=xxx.dmp logfile=xxx_impdp.log full=y;
可选参数
schemas=username
remap_schema= Test:Test
remap_tablespace= Test:Test
5.数据库备份(cmd窗口运行):
expdp Test/Test@orcl directory=cad dumpfile=Test1028.DMP logfile=Test1028.log;
4、导入报错"IMP-00017: 由于 ORACLE 错误 6550, 以下语句失败:"解决方案
--导入语句加参数
statistics=none
可以先不导入统计信息,等数据导入完成后,空闲时间重新生成统计信息。
statistics参数官方说明如下:
STATISTICS
缺省值:ALWAYS
说明:指定导入时关于数据库统计信息如何处理
有如下选项:
ALWAYS:总是导入数据库统计信息.
NONE:不导入数据库统计信息.
SAFE:当dmp中统计住处没有问题时导入数据库统计信息,如果有问题,则重新生成统计信息.
RECALCULATE:总是重新生成统计信息.
5、空表导出空表
1.初始设置(只对该命令执行后新增表起作用,已有表不起作用) sqlplus sys/oracle as sysdba;
show parameter deferred_segment_creation;
alter system set deferred_segment_creation=false;
2.对已有表,执行下面语句后,把结果再执行
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0