出处:http://blog.csdn.net/yh_zeng2 http://blog.csdn.net/yh_zeng2/article/details/76544794
1、创建用户与表空间
1)创建表空间
- CREATE TABLESPACE test
- LOGGING
- DATAFILE ’E:\oradata\test.DBF’
- SIZE 32M
- AUTOEXTEND ON
- NEXT 1M
- EXTENT MANAGEMENT LOCAL;
CREATE TABLESPACE test
LOGGING
DATAFILE 'E:\oradata\test.DBF'
SIZE 32M
AUTOEXTEND ON
NEXT 1M
EXTENT MANAGEMENT LOCAL;
2)创建用户并指定表空间
- CREATE USER test IDENTIFIED BY test
- DEFAULT TABLESPACE test
- TEMPORARY TABLESPACE TEMP;
CREATE USER test IDENTIFIED BY test
DEFAULT TABLESPACE test
TEMPORARY TABLESPACE TEMP;
3)给用户授权DBA权限
- GRANT connect,dba TO test;
GRANT connect,dba TO test;
4)给用户授权,可以创建DBLINK
- GRANT create database link to test;
GRANT create database link to test;
2、删除用户和表空间
1)删除用户和用户相关的数据
- drop user test cascade;
drop user test cascade;
2)删除表空间和相应文件
- drop tablespace test including contents and datafiles;
drop tablespace test including contents and datafiles;
3、imp/exp导入导出
1)imp导入
- imp test/test@ORCL file=F:\数据库备份\broker[2015-06-26].dmp fromuser=sirm touser=yh_test log=F:\数据库备份\broker[2015-06-26]_imp.log ignore=y
imp test/test@ORCL file=F:\数据库备份\broker[2015-06-26].dmp fromuser=sirm touser=yh_test log=F:\数据库备份\broker[2015-06-26]_imp.log ignore=y
2)exp导出
- exp test/test@RTJJ file=F:\数据库备份\2015-07-10.dmp tables=(RT_OUTGOINGREQUEST,RT_TRADESURVEYLOG,RT_TRADESURVEYLOGDOC) log=F:\数据库备份\2015-07-10.log
exp test/test@RTJJ file=F:\数据库备份\2015-07-10.dmp tables=(RT_OUTGOINGREQUEST,RT_TRADESURVEYLOG,RT_TRADESURVEYLOGDOC) log=F:\数据库备份\2015-07-10.log
4、impdp/expdp导入导出
该方案可以解决oracle高版本导出数据库数据,低版本Oracle无法导入的bug,通过导出的时候指定版本号解决1)创建directory
- CREATE OR REPLACE DIRECTORY dmpdir AS ‘E:\公司资料\数据备份’;
- GRANT read, write ON DIRECTORY dmpdir TO test;
CREATE OR REPLACE DIRECTORY dmpdir AS 'E:\公司资料\数据备份';
GRANT read, write ON DIRECTORY dmpdir TO test;
2)远程导出/导入
使新创建的用户test登录并创建数据库连接DBLINK:- sqlplus test/test as sysdba;
- create public database link dlink_test connect to test identified by test using ‘test’; – using ‘test’中,test是远程服务名,是在Net Manager配置的服务命名,也可以使用127.0.0.1/orcl
sqlplus test/test as sysdba;
create public database link dlink_test connect to test identified by test using 'test'; -- using 'test'中,test是远程服务名,是在Net Manager配置的服务命名,也可以使用127.0.0.1/orcl
远程导出:
- EXPDP test/test DIRECTORY=dmpdir NETWORK_LINK=dlink_test
- DUMPFILE=test.dmp SCHEMAS=test LOGFILE=test_expdp.log version=10.2.0.4.0
EXPDP test/test DIRECTORY=dmpdir NETWORK_LINK=dlink_test
DUMPFILE=test.dmp SCHEMAS=test LOGFILE=test_expdp.log version=10.2.0.4.0
远程导入:
- impdp test/test DIRECTORY=dmpdir NETWORK_LINK=dlink_test SCHEMAS=test
- remap_schema=test2:test remap_tablespace=test2:test table_exists_action=REPLACE LOGFILE=test_import.log
impdp test/test DIRECTORY=dmpdir NETWORK_LINK=dlink_test SCHEMAS=test
remap_schema=test2:test remap_tablespace=test2:test table_exists_action=REPLACE LOGFILE=test_import.log
3)本地导出/导入
本地导出:- EXPDP test/test@orcl DIRECTORY=dmpdir DUMPFILE=test.dmp SCHEMAS=test LOGFILE=test_expdp.log version=10.2.0.4.0
EXPDP test/test@orcl DIRECTORY=dmpdir DUMPFILE=test.dmp SCHEMAS=test LOGFILE=test_expdp.log version=10.2.0.4.0
本地导入:
- impdp test/test@orcl DIRECTORY=dmpdir DUMPFILE=test2.dmp SCHEMAS=test
- remap_schema=test2:test remap_tablespace=test2:test table_exists_action=REPLACE LOGFILE=test2_import.log
impdp test/test@orcl DIRECTORY=dmpdir DUMPFILE=test2.dmp SCHEMAS=test
remap_schema=test2:test remap_tablespace=test2:test table_exists_action=REPLACE LOGFILE=test2_import.log
5、查看所有的DIRECTORY 目录
- select * from dba_directories;
select * from dba_directories;
</div>