--查看用户的表空间
select d.default_tablespace,d.* from dba_users d where d.username = 'D_B';--USER_DATA
--查看表空间位置
select * FROM DBA_DATA_FILES d where d.tablespace_name = 'USER_DATA';
--查看连接用户的会话信息
select v.sid,v.serial#,v.* from v$session v where v.username='D_E';
--kill会话
alter system kill session '205,28571';
--1.删除用户
drop user D_B cascade;
drop user D_V cascade;
drop user D_BA cascade;
drop user D_C cascade;
drop user D_E cascade;
--查询用户
select * from dba_users d where d.username like '%DEMO%';
--2.删除表空间
drop tablespace USER_DATA including contents and datafiles;
--3.创建表空间
create tablespace demo_data
DATAFILE '/test/bl/dbfile/demo_data.dbf' Size 500M
Autoextend ON
NEXT 50M
Maxsize unlimited;
--创建用户
create user D_E identified by D_E
default tablespace demo_data;
create user D_C identified by D_C
default tablespace demo_data;
create user D_B identified by D_B
default tablespace demo_data;
create user D_V identified by D_V
default tablespace demo_data;
create user D_BA identified by D_B
default tablespace demo_data;
--5赋权
grant connect,resource to D_E;
grant connect,resource to D_C;
grant connect,resource to D_B;
grant connect,resource to D_V;
grant connect,resource to D_BA;
select * from dba_directories;
--导入语句
impdp system/123456 directory=ORADATA dumpfile=190711.dmp logfile=IMP_ALL190711.log remap_schema=D_E:D_E,D_C:D_C,D_B:D_B,D_V:D_V,D_BA:D_BA
--检查用户
select * from all_tables a where a.OWNER = 'D_B';
select * from all_tables a where a.OWNER = 'D_V';
select * from all_tables a where a.OWNER = 'D_BA';
select * from all_tables a where a.OWNER = 'D_C';
select * from all_tables a where a.OWNER = 'D_E';
--赋权
grant dba to D_B;
expdp D_E/D_E directory=dumpdir dumpfile=PRODUCTION22.dmp schemas=A_E,A_C,A_B,A_BA,A_V logfile=sxx3.log
exp ned/tr@ned file=C:\dmp\20191019.dmp tables=(CUSTOMER,PROCESSDATE)
--查询session
select v.sid,v.serial#,v.* from v$session v where v.username='NED';
--杀掉被占用的用户
alter system kill session '6,3343';
--删除用户
drop user ned cascade;
--删除表空间
drop tablespace NED including contents and datafiles;
--查看表空间位置
select * FROM DBA_DATA_FILES d where d.tablespace_name = 'NED';
--创建表空间
create tablespace NED
DATAFILE 'D:\oradata\bl\dbfile\NED.DBF' Size 500M
Autoextend ON
NEXT 50M
Maxsize unlimited;
--创建用户
create user ned identified by tr
default tablespace NED;
--5赋权
grant connect,resource to ned;
grant create session to ned;
grant dba to ned with admin option;
--导入语句
imp scott/tiger buffer=10000 file="D:\oradata\dmp\20191104.dmp" fromuser=ned touser=ned
--检查用户
select * from all_tables a where a.OWNER = 'ned';
--查询数据泵
select * from dba_directories d where d.directory_name = 'ORADATA' for update nowait;
--创建数据泵
create directory ORADATA as 'D:\oradata\dmp\';
--删除数据泵
delete from dba_directories d where d.directory_name = 'ORADATA';
--查看连接用户的会话信息
select v.sid,v.serial#,v.* from v$session v where v.username='A_B';
--kill会话
alter system kill session '75,35';
--删除用户
drop user A_B cascade;
drop user A_V cascade;
drop user A_BA cascade;
drop user A_C cascade;
drop user A_E cascade;
--2.删除表空间
drop tablespace alpha_data including contents and datafiles;
--3.创建表空间
create tablespace alpha_data
DATAFILE 'D:\oradata\bl\dbfile\alpha_data.dbf' Size 500M
Autoextend ON
NEXT 50M
Maxsize unlimited;
--查询所有用户
select * from all_users;
--创建用户
create user A_E identified by A_E
default tablespace alpha_data;
create user A_C identified by A_C
default tablespace alpha_data;
create user A_B identified by A_B
default tablespace alpha_data;
create user A_V identified by A_V
default tablespace alpha_data;
create user A_BA identified by A_BA
default tablespace alpha_data;
--5赋权
grant connect,resource to A_E;
grant connect,resource to A_C;
grant connect,resource to A_B;
grant connect,resource to A_V;
grant connect,resource to A_BA;
--授权
grant read,write on directory ORADATAS to scott;
grant dba to scott;
--导入语句
impdp scott/tiger directory=ORADATAS dumpfile=PH_20191104_225051.dmp logfile=IMP_1108.log remap_schema=A_E:A_E,A_C:A_C,A_B:A_B,A_V:A_V,A_BA:A_BA