均在服务器端
oracle11g数据导出
–创建目录
先在D盘创建物理路径D:\dump
进入sqlplus
sqlplus / as sysdba
创建逻辑目录
create or replace directory dir as 'D:\dump';
–授权
grant read,write on directory dir to SZGW_YS;
–查询
select * from dba_directories;
退出sqlplus
ctrl+c
–导出
expdp SZGW_YS/SZGW_YS@orcl schemas=SZGW_YS dumpfile=SZGW_YS.dmp DIRECTORY=dir
–删除
drop directory dir;
数据导入Oracle12C
–登录cdb
sqlplus system/cnten as sysdba
–查询当前容器
show con_name
–查询容器中所有pdb
show pdbs
–创建pdb数据库
CREATE pluggable DATABASE pdborcl admin USER pdbadmin identified BY pdbadmin roles=(connect)
file_name_convert= ('C:\app\Administrator\oradata\orcl\pdbseed', 'C:\app\Administrator\oradata\orcl\pdborcl');
–切换到pdb数据库
alter session set container=pdborcl
–打开数据库
alter database open
–创建目录
先在c盘创建物理目录C:\dump
并将导出的DMP文件存放到该目录下
create or replace directory dir as 'C:\dump';
–查询
select * from dba_directories;
–1:创建临时表空间
create temporary tablespace SZGW_YS_TEMP
tempfile 'C:\app\Administrator\oradata\orcl\tablespace\SZGW_YS_TEMP.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
–创建数据表空间
create tablespace SZGW_YS_DATA
datafile 'C:\app\Administrator\oradata\orcl\tablespace\SZGW_YS_DATA.dbf'
size 50m
autoextend on
next 50m maxsize 20480m
extent management local;
–删除用户
drop user SZGW_YS cascade;
–第3步:创建用户并指定表空间
create user SZGW_YS identified by SZGW_YS default tablespace SZGW_YS_DATA temporary tablespace SZGW_YS_TEMP;
–第4步:给用户授予权限
grant connect,resource,dba to SZGW_YS;
–授权
grant read,write on directory dir to SZGW_YS;
–查看目录及权限
SELECT privilege, directory_name, DIRECTORY_PATH FROM user_tab_privs t, all_directories d
WHERE t.table_name(+) = d.directory_name ORDER BY 2, 1;
–退出sqlplus
ctrl+c
–使用impdp导入SZGW_YS数据
impdp SZGW_YS/SZGW_YS@pdborcl directory=dir dumpfile=SZGW_YS.DMP TABLE_EXISTS_ACTION=replace version='11.2.0.1.0' transform=segment_attributes:n
remap_tablespace=tbs_hr:tbshr 原来表空间:新的表空间
remap_schema=hr:hradm 原来的schema:现在的schema
transform=segment_attributes:n 去掉表空间和存储子句,加上这个参数后,remap_tablesapce参数就会失效,就会倒进用户默认的表空间,