---1.0 查询存在的用户
Select * From Dba_Users
---2.0 获取表空间的路径
Select File#, Name From V$datafile;
---3.0 创建表空间 和新增表空间
Select Distinct ‘CREATE SMALLFILE TABLESPACE "‘ || a.Tablespace_Name ||
‘" DATAFILE ‘ || ‘‘‘‘ || ‘C:\app\Administrator\oradata‘ ||
a.Tablespace_Name || ‘01‘ || ‘‘‘‘ ||
‘ SIZE 100M AUTOEXTEND ON NEXT 100M MAXSIZE 8G LOGGING EXTENT MANAGEMENT LOCAL SEGMENT SPACE MANAGEMENT AUTO ;‘ 创建表空间,
‘ALTER TABLESPACE "‘ || a.Tablespace_Name || ‘" DATAFILE ‘ || ‘‘‘‘ ||
‘C:\app\Administrator\oradata‘ || a.Tablespace_Name || ‘02‘ || ‘‘‘‘ ||
‘ SIZE 100M REUSE AUTOEXTEND ON NEXT 100M MAXSIZE 1G;‘ 增加表空间
From Dba_Data_Files a, Dba_Users b
Where a.Tablespace_Name = b.Default_Tablespace
And b.Account_Status = ‘OPEN‘;
---4.0 创建用户
Select Distinct ‘CREATE USER "‘ || b.Username ||
‘" PROFILE "DEFAULT" IDENTIFIED BY "‘ || b.Username ||
‘" DEFAULT TABLESPACE "‘ || a.Tablespace_Name ||
‘" TEMPORARY TABLESPACE "TEMP" ACCOUNT UNLOCK;‘ 创建用户,
‘grant connect,resource,dba,exp_full_database,imp_full_database to ‘ ||
b.Username || ‘;‘ 授权语句
From Dba_Data_Files a, Dba_Users b
Where a.Tablespace_Name = b.Default_Tablespace
And b.Account_Status = ‘OPEN‘;--用户状态Open 正常用的
---5.0 导出/导入
导出:
1 将数据库TEST完全导出,用户名system 密码manager 导出到D:\daochu.dmp中
exp System/manager@Hyzyyzs file=d:\XX.dmp full=y Log=;
2 将数据库中system用户与sys用户的表导出
exp System/manager@Hyzyyzs file=d:\XX.dmp owner=(system,sys) Log=;
3 将数据库中的表table1 、table2导出
exp System/manager@Hyzyyzs file=d:\XX.dmp tables=(table1,table2) Log=;
4 将数据库中的表table1中的字段filed1以"00"打头的数据导出
exp System/manager@Hyzyyzs file=d:\XX.dmp tables=(table1) query=" where filed1 like ‘00%‘" Log=;
导入:
Imp System/manager@Hyzyyzs Rows = y Ignore = y Statistics = None Fromuser = His3 Touser = His3 File =C:\XX.dmp Log =C:\XX.Log; 导入多个用户的时候 (XX1,XX2,XX3)