select ‘alter system kill session ‘’’||s.sid||’,’||s.serial#||’’’;’ from v$session s where username=‘HNYYJSXY’;
alter system kill session ‘33,12055’;
alter system kill session ‘604,31771’;
alter system kill session ‘1160,57385’;
alter system kill session ‘1166,47577’;
alter system kill session ‘1731,7253’;
alter system kill session ‘1751,7643’;
alter system kill session ‘1756,7083’;
drop user hnyyjsxy cascade;
drop tablespace hnyyjsxy including contents and datafiles;
create tablespace hnyyjsxy datafile ‘/oradata/database/hnyyjsxy /hnyyjsxy .dbf’ size 1024M autoextend on next 50m maxsize unlimited;
/*create tablespace ncdx2015 datafile ‘/oradata/database/ncdx/ncdx2015.dbf’ size 3000M autoextend on next 50m maxsize unlimited extent management local segment space management auto;
*/
create tablespace hnyyjsxy datafile ‘/oradata/database/hnyyjsxy /hnyyjsxy .dbf’ size 10m autoextend on next 10m maxsize 32767m,’/oradata/database/hnyyjsxy /hnyyjsxy 1.dbf’ size 10m autoextend on next 10m maxsize 32767m;
create user hnyyjsxy identified by hnyyjsxy default tablespace hnyyjsxy;
grant resource,connect,dba,create any procedure,create any table to hnyyjsxy;
grant read,write on directory hnyyjsxy to hnyyjsxy ;
su - oracle
df -k
imp hnyyjsxy/[email protected] file=/oradata/database/hnyyjsxy/hnyyjsxy.dmp log=/oradata/database/hnyyjsxy/hnyyjsxy.log fromuser=hnyyjsxy touser=hnyyjsxy
file和log的路径一定要正确
create directory hnyyjsxy as ‘/oradata/database/hnyyjsxy’;
select * from dba_directories
delete from dba_directories where directory_name=‘HNYYJSXY’
su - oracle
df -k
impdp/路径(.dmp文件存放):/oracle/dpdump
dumpfile和logfile的路径一定要正确
impdp hnyyjsxy/[email protected]/orcl dumpfile=hnyyjsxy.dmp logfile=hnyyjsxy.log schemas=hnyyjsxy directory=hnyyjsxy
/*
impdp hnyyjsxy/[email protected] schemas=hnyyjsxy dumpfile=hnyyjsxy.dmp directory=hnyyjsxy job_name=hnyyjsxy logfile=hnyyjsxy.log
*/
impdp njnydx/[email protected] schemas=hnyyjsxy dumpfile=hnyyjsxy.dmp directory=hnyyjsxy logfile=hnyyjsxy .log gfile=hnyyjsxy.log
drop user hnyyjsxy cascade; --删除用户
drop tablespace hnyyjsxy including contents and datafiles; --删除表空间
select ‘alter system kill session ‘’’||s.sid||’,’||s.serial#||’’’;’ from v$session s where username=‘hnyyjsxy’;–强制删除连接
alter system kill session ‘33,12055’;
alter system kill session ‘604,31771’;
alter system kill session ‘1160,57385’;
alter system kill session ‘1166,47577’;
alter system kill session ‘1731,7253’;
alter system kill session ‘1751,7643’;
alter system kill session ‘1756,7083’;
–创建表空间
create tablespace szjsdx datafile ‘/oradata/database/hnyyjsxy/hnyyjsxy.dbf’ size 1024M autoextend on next 50m maxsize unlimited;
/*create tablespace ncdx2015 datafile ‘/oradata/database/ncdx/ncdx2015.dbf’ size 3000M autoextend on next 50m maxsize unlimited extent management local segment space management auto;
*/
–创建两个表空间
create tablespace hnyyjsxy datafile ‘/oradata/database/hnyyjsxy/hnyyjsxy.dbf’ size 10m autoextend on next 10m maxsize 32767m,’/oradata/database/hnyyjsxy/hnyyjsxy1.dbf’ size 10m autoextend on next 10m maxsize 32767m;
create user hnyyjsxy identified by hnyyjsxy default tablespace hnyyjsxy; --创建用户名
grant resource,connect,dba,create any procedure,create any table to hnyyjsxy; – -创建权限
–建立数据泵目录
create directory hnyyjsxy as ‘/oradata/database/hnyyjsxy’; —创建一次就可以了
select * from dba_directories --查看泵导目录
delete from dba_directories where directory_name=‘hnyyjsxy’
–给相关用户授权
grant read,write on directory hnyyjsxy to hnyyjsxy;
–切换到oracle用户
su - oracle
查看磁盘空间
df -k
(Linux)
2) 和windows里一样使用imp等命令还原数据库
imp hnyyjsxy/[email protected] file=/oradata/database/hnyyjsxy/hnyyjsxy28.dmp log=/oradata/database/hnyyjsxy/hnyyjsxy.log fromuser=hnyyjsxy touser=hnyyjsxy
impdp/路径(.dmp文件存放):/oracle/dpdump
impdp hnyyjsxy/[email protected]/orcl dumpfile=hnyyjsxy.dmp logfile=hnyyjsxy.log schemas=hnyyjsxy directory=hnyyjsxy
/*
impdp ncdx2015/[email protected] schemas=ncdx2015 dumpfile=ncdx201520161128.dmp directory=NCDX2015 job_name=ncdx2015 logfile=ncdx20161217.log
*/
impdp njnydx/[email protected] schemas=njnydx dumpfile=20171218.dmp directory=NJNYDX1 logfile=20171218.log
gfile=20171218.log