创建用户:
1,sqlplus sys/pwd as sysdba;
2, create user username identified by password;
3, grant dba,connect,resource to username;
查看表空间使用情况:
SELECT UPPER(F.TABLESPACE_NAME) "表空间名",
D.TOT_GROOTTE_MB "表空间大小(M)",
D.TOT_GROOTTE_MB - F.TOTAL_BYTES "已使用空间(M)",
TO_CHAR(ROUND((D.TOT_GROOTTE_MB - F.TOTAL_BYTES) / D.TOT_GROOTTE_MB * 100,2),‘990.99‘) || ‘%‘ "使用比",
F.TOTAL_BYTES "空闲空间(M)",
F.MAX_BYTES "最大块(M)"
FROM (SELECT TABLESPACE_NAME,
ROUND(SUM(BYTES) / (1024 * 1024), 2) TOTAL_BYTES,
ROUND(MAX(BYTES) / (1024 * 1024), 2) MAX_BYTES
FROM SYS.DBA_FREE_SPACE
GROUP BY TABLESPACE_NAME) F,
(SELECT DD.TABLESPACE_NAME,
ROUND(SUM(DD.BYTES) / (1024 * 1024), 2) TOT_GROOTTE_MB
FROM SYS.DBA_DATA_FILES DD
GROUP BY DD.TABLESPACE_NAME) D
WHERE D.TABLESPACE_NAME = F.TABLESPACE_NAME
ORDER BY 1;
exp导出dmp文件:
EXP SYSTEM/MANAGER BUFFER=64000 FILE=D:\FULL.DMP FULL=Y
IMP SYSTEM/MANAGER BUFFER=64000 FILE=D:\FULL.DMP FULL=Y
imp指定表空间:
1.创建表空间
create tablespace example_tablespace datafile ‘D:\****.dmp‘ size 1024m reuse autoextend on next 4m maxsize unlimited;
2.创建用户,指定表空间,临时表空间
create user username identified by password default tablespace example_tablespace temporary tablespace temp;
3.IMP导入数据库文件注意
grant dba to username;DBA权限是必需的
一般默认导入的表空间是导出时候的表空间
revoke unlimited tablespace from username;// 撤销此权限
alter user username quota 0 on users; // 将用户在 users 表空间的配额置为 0
alter user username quota unlimited on example_tablespace;// 设置在用户在 example_tablespace表空间配额不受限。
imp username/password file=‘D:\***.dmp‘ tablespaces=example_tablespace log=‘D:\imp_log.txt‘