linux oracle操作

常用启动关闭

(1) 以oracle身份登录数据库,命令:su – oracle

(2) 进入Sqlplus控制台,命令:sqlplus /nolog

(3) 以系统管理员登录,命令:connect / as sysdba

(4) 启动数据库,命令:startup

(5) 如果是关闭数据库,命令:shutdown immediate

(6) 退出sqlplus控制台,命令:exit

(7) 进入监听器控制台,命令:lsnrctl

(8) 启动监听器,命令:start    ;  停止监听:stop

(9) 退出监听器控制台,命令:exit

(10) 重启数据库结束

 

 

 

导入导出数据:

从一个用户expdp导出再impdp导入到另一个用户

存在分区表使用expdp:

create user kms identified by kms;

grant connect, resource,dba to kms

 

前置条件,需要登录进sqlplus添加文件夹权限:

例如:

create directory dump_dir as '/u01/app/oracle';

grant read,write on directory dump_dir to kms;

 

expdp kms_temp/kms_temp directory=dump_dir dumpfile=kms_temp_20180905_init.dmp

impdp "kms/kms" directory=dump_dir dumpfile=kms_temp_20180905_init.dmp  REMAP_SCHEMA=kms_temp:kms

 

drop user kms cascade;

SELECT SID, SERIAL# FROM V$SESSION WHERE USERNAME = 'KMS';

impdp kms/kms directory=dumpdir dumpfile=kms_temp_20180904.dmp REMAP_SCHEMA=user1:user2

 

 

如果想导入的用户已经存在:

1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp

2. 导入用户 impdp user2/pass2 directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2 EXCLUDE=USER

如果想导入的用户不存在:

1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp

2. 导入用户 impdp system/passsystem directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2

如果想导入的用户已经存在:

1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp

2. 导入用户 impdp user2/pass2 directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2 EXCLUDE=USER

如果想导入的用户不存在:

1. 导出用户 expdp user1/pass1 directory=dumpdir dumpfile=user1.dmp

2. 导入用户 impdp system/passsystem directory=dumpdir dumpfile=user1.dmp REMAP_SCHEMA=user1:user2

 

 

普通导入导出:

imp test/test@test fromuser=kms touser=test_temp file=F:\test.dmp ignore=y

exp test/test@testowner=kms file=/home/oracle/test_20180709.dmp

你可能感兴趣的:(linux oracle操作)