--表分析
select 'analyze table '||table_name||' compute statistics;' from user_tables;
--查询空表
select table_name,num_rows from user_tables where num_rows = 0;
--给空表分配空间
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows = 0 ;
*******************************************************************************************************************
*******************************************************************************************************************
--导出dmp文件
exp user/pass file=F:\hzfx20160419.dmp owner=(hzfx_dev) indexes=n statistics=none
exp user/pass@192.168.70.191/orcl file=F:\a.dmp owner=hzfx_dev statistics=none
exp user/pass@192.168.70.191/orcl file=F:\b.dmp owner=(hzfx_dev) indexes=n statistics=none
exp hztest/hztest@192.168.1.104/orcl file=F:\c.dmp owner=(hztest) indexes=n statistics=none
--导入dmp文件
imp user/pass@LOCAL file=D:\JOYINTECH\ZCGLDB_20141026210820.dmp full=y ignore=y
impbd user/pass@LOCAL file=D:\JOYINTECH\ZCGLDB_20141026210820.dmp full=y ignore=y
impdp user/pass@LOCAL directory=DATA_PUMP_DIR dumpfile=D:\app\oracle\admin\orcl\dpdump\ZCGLDB_20141026210820.dmp
imp user/pass@LOCAL file=D:\JOYINTECH\ZCGLDB_20141026210820.dmp fromuser=hzsc touser=hzsc
exp user/pass@LOCAL file=D:\ZCGLDB.dmp owner=ZCGLDB
*******************************************************************************************************************
*******************************************************************************************************************
删除用户drop user hzsc cascade;
1:创建临时表空间
create temporary tablespace user_temp
tempfile 'Q:\oracle\product\10.2.0\oradata\Test\xyrj_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
2:创建数据表空间
create tablespace user_data
logging
datafile 'Q:\oracle\product\10.2.0\oradata\Test\xyrj_data.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
第3步:创建用户并指定表空间
create user user identified by user
default tablespace user_data
temporary tablespace user_temp;
第4步:给用户授予权限
grant connect,resource,dba to user
-Xms512m -Xmx1024m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=512m
*******************************************************************************************************************
*******************************************************************************************************************
在本地oracle建立数据泵
1、创建DIRECTORY
create directory dmp_dir as 'E:\oracle\win64_11gR2_database\database';
2、授权
grant read,write on directory DATABF to user;
然后执行
impdp user/pass@LOCAL DIRECTORY=dmp_dir DUMPFILE=ZCGLDB_20141026210820.dmp
Alter user hzsc default tablespace hzsc quota unlimited on hzsc;
grant create session to hzsc;
grant connect to hzsc;
grant connect, resource, dba to hzsc;
grant create table to hzsc;
grant create view to hzsc;
grant create trigger to hzsc;
grant select any table to hzsc;
grant create sequence to hzsc;
grant create procedure to hzsc;
grant create role to hzsc;
grant create type to hzsc;
grant GRANT ANY PRIVILEGE to hzsc;
create directory dump_dir as 'D:\app\oracle\admin\orcl\dpdump';
IMPDP USERID='user/pass@LOCAL' directory=DATA_PUMP_DIR schemas= ZCGLDB
dumpfile=ZCGLDB_20141026210820.dmp logfile=dag.log;
impdp user/pass directory=DATA_PUMP_DIR dumpfile=ZCGLDB_20141026210820.dmp sqlfile=sec_expdp.sql TRANSFORM=segment_attributes:n
*******************************************************************************************************************
*******************************************************************************************************************
select * from dba_directories
expdp与impdp命令
2014年10月27日
15:49
expdp与impdp命令
在cmd 环境中
连接数据库
sqlplus username/password@orcl
连接后,创建目录
SQL>create directory databf as 'd:\oracle\bf'
授权
SQL>grant read,write on directory databf to user
导出整个数据库
expdp user/user schemas=user DIRECTORY=databf DUMPFILE=ZCGLDB_2015.dmp full=y;
导入整个数据库
impdp user/pass DIRECTORY=databf DUMPFILE=ZCGLDB_20141026210820.dmp full=y;
若发现导入时有错误时需用transform去掉表空间和存储子句
impdp user/user DIRECTORY=databf DUMPFILE=ZCGLDB_20150227192901.dmp TRANSFORM=segment_attributes:n full=y;
*************************************************************导出DMP文件start*************************************************************
exp user/user owner=ZCGLDB file=E:\CHECKOUT_HZ\user.dmp
*************************************************************导出DMP文件 end*************************************************************
*************************************************************导入DMP文件start*************************************************************
imp lczcgl/lczcgl file=F:\app\bf\lczcgl20151021.dmp fromuser=lczcgl touser=lczcgl ignore=y
1、创建用户create user lczcgl identified by lczcgl
2、给用户授予权限grant connect,resource,dba to lczcgl
3、创建DIRECTORYcreate directory DATABF as 'F:\app\bf' (将dmp文件放入目标文件夹中)
4、授权grant read,write on directory DATABF to lczcgl;
4、导入impdp lczcgl/lczcgl DIRECTORY=databf DUMPFILE=lczcgl20151021.dmp TRANSFORM=segment_attributes:n full=y;
*************************************************************导入DMP文件 end*************************************************************
*************************************************************解决空表问题 *************************************************************
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0
impdp cdtis2/cdtis2 DIRECTORY=DATABF DUMPFILE=cd20150721.dmp remap_schema=cdbk:cdtis2 remap_tablespace=CDBK_DATA:tis TRANSFORM=segment_attributes:n full=y;
/*
*说明:cdbk是他原来的表空间和库名,cdtis2是新创建的库名,tis是这个库名的表空间。
*/
select 'analyze table '||table_name||' compute statistics;' from user_tables;
--查询空表
select table_name,num_rows from user_tables where num_rows = 0;
--给空表分配空间
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows = 0 ;
*******************************************************************************************************************
*******************************************************************************************************************
--导出dmp文件
exp user/pass file=F:\hzfx20160419.dmp owner=(hzfx_dev) indexes=n statistics=none
exp user/pass@192.168.70.191/orcl file=F:\a.dmp owner=hzfx_dev statistics=none
exp user/pass@192.168.70.191/orcl file=F:\b.dmp owner=(hzfx_dev) indexes=n statistics=none
exp hztest/hztest@192.168.1.104/orcl file=F:\c.dmp owner=(hztest) indexes=n statistics=none
--导入dmp文件
imp user/pass@LOCAL file=D:\JOYINTECH\ZCGLDB_20141026210820.dmp full=y ignore=y
impbd user/pass@LOCAL file=D:\JOYINTECH\ZCGLDB_20141026210820.dmp full=y ignore=y
impdp user/pass@LOCAL directory=DATA_PUMP_DIR dumpfile=D:\app\oracle\admin\orcl\dpdump\ZCGLDB_20141026210820.dmp
imp user/pass@LOCAL file=D:\JOYINTECH\ZCGLDB_20141026210820.dmp fromuser=hzsc touser=hzsc
exp user/pass@LOCAL file=D:\ZCGLDB.dmp owner=ZCGLDB
*******************************************************************************************************************
*******************************************************************************************************************
删除用户drop user hzsc cascade;
1:创建临时表空间
create temporary tablespace user_temp
tempfile 'Q:\oracle\product\10.2.0\oradata\Test\xyrj_temp.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
2:创建数据表空间
create tablespace user_data
logging
datafile 'Q:\oracle\product\10.2.0\oradata\Test\xyrj_data.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
第3步:创建用户并指定表空间
create user user identified by user
default tablespace user_data
temporary tablespace user_temp;
第4步:给用户授予权限
grant connect,resource,dba to user
-Xms512m -Xmx1024m -XX:PermSize=128M -XX:MaxNewSize=256m -XX:MaxPermSize=512m
*******************************************************************************************************************
*******************************************************************************************************************
在本地oracle建立数据泵
1、创建DIRECTORY
create directory dmp_dir as 'E:\oracle\win64_11gR2_database\database';
2、授权
grant read,write on directory DATABF to user;
然后执行
impdp user/pass@LOCAL DIRECTORY=dmp_dir DUMPFILE=ZCGLDB_20141026210820.dmp
Alter user hzsc default tablespace hzsc quota unlimited on hzsc;
grant create session to hzsc;
grant connect to hzsc;
grant connect, resource, dba to hzsc;
grant create table to hzsc;
grant create view to hzsc;
grant create trigger to hzsc;
grant select any table to hzsc;
grant create sequence to hzsc;
grant create procedure to hzsc;
grant create role to hzsc;
grant create type to hzsc;
grant GRANT ANY PRIVILEGE to hzsc;
create directory dump_dir as 'D:\app\oracle\admin\orcl\dpdump';
IMPDP USERID='user/pass@LOCAL' directory=DATA_PUMP_DIR schemas= ZCGLDB
dumpfile=ZCGLDB_20141026210820.dmp logfile=dag.log;
impdp user/pass directory=DATA_PUMP_DIR dumpfile=ZCGLDB_20141026210820.dmp sqlfile=sec_expdp.sql TRANSFORM=segment_attributes:n
*******************************************************************************************************************
*******************************************************************************************************************
select * from dba_directories
expdp与impdp命令
2014年10月27日
15:49
expdp与impdp命令
在cmd 环境中
连接数据库
sqlplus username/password@orcl
连接后,创建目录
SQL>create directory databf as 'd:\oracle\bf'
授权
SQL>grant read,write on directory databf to user
导出整个数据库
expdp user/user schemas=user DIRECTORY=databf DUMPFILE=ZCGLDB_2015.dmp full=y;
导入整个数据库
impdp user/pass DIRECTORY=databf DUMPFILE=ZCGLDB_20141026210820.dmp full=y;
若发现导入时有错误时需用transform去掉表空间和存储子句
impdp user/user DIRECTORY=databf DUMPFILE=ZCGLDB_20150227192901.dmp TRANSFORM=segment_attributes:n full=y;
*************************************************************导出DMP文件start*************************************************************
exp user/user owner=ZCGLDB file=E:\CHECKOUT_HZ\user.dmp
*************************************************************导出DMP文件 end*************************************************************
*************************************************************导入DMP文件start*************************************************************
imp lczcgl/lczcgl file=F:\app\bf\lczcgl20151021.dmp fromuser=lczcgl touser=lczcgl ignore=y
1、创建用户create user lczcgl identified by lczcgl
2、给用户授予权限grant connect,resource,dba to lczcgl
3、创建DIRECTORYcreate directory DATABF as 'F:\app\bf' (将dmp文件放入目标文件夹中)
4、授权grant read,write on directory DATABF to lczcgl;
4、导入impdp lczcgl/lczcgl DIRECTORY=databf DUMPFILE=lczcgl20151021.dmp TRANSFORM=segment_attributes:n full=y;
*************************************************************导入DMP文件 end*************************************************************
*************************************************************解决空表问题 *************************************************************
select 'alter table '||table_name||' allocate extent;' from user_tables where num_rows=0
impdp cdtis2/cdtis2 DIRECTORY=DATABF DUMPFILE=cd20150721.dmp remap_schema=cdbk:cdtis2 remap_tablespace=CDBK_DATA:tis TRANSFORM=segment_attributes:n full=y;
/*
*说明:cdbk是他原来的表空间和库名,cdtis2是新创建的库名,tis是这个库名的表空间。
*/