oracle

---查看表空间大小
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

 
--查看表空间存放的位置
select name from v$datafile;

--查看表空间是否自动扩展
select tablespace_name,file_name,autoextensible from dba_data_files where tablespace_name = 'XXX';

--数据库表空间增加10G
alter tablespace XXX add datafile 
'D:\APP\ADMINISTRATOR\ORADATA\lambert\lambert_DATA8.DBF' size 5120M
AUTOEXTEND ON NEXT 1310720 MAXSIZE 10240M;


create tablespace XXXX datafile 'F:\oracle\product\10.1.0\oradata\news\news_data.dbf' size 500M;


imp aichannel/aichannel@HUST file=d:\data\newsmgnt.dmp

--创建用户
create user lambert identified by XXXXX
--创建表空间
create tablespace lambert_DATA datafile '/home/oracle/oracle/oradata/lambert/lambert01.dbf' size 5120M AUTOEXTEND ON NEXT 1310720 MAXSIZE 10240M;
alter user lambert default tablespace lambert_DATA;
create user lambert_sss identified by xxxxxxx default tablespace sss_DATA;

--分配权限
grant connect,resource to lambert_sss; 
grant dba to lambert_sss;
grant create session,create table,unlimited tablespace to sss;

alter user lambert identified by xxxxxx;

--导入导出数据内容

exp lambert_sss/xxxxxxx@localhost/lambert file=lambert_sss-20171110.dmp log=lambert_sss-20171110.log owner=lambert_sss
imp lambert_sss/xxxxxxx@localhost/lambert file=lambert_sss-20171110.dmp fromuser=lambert_sss touser=lambert_sss ignore=y

--导入导出数据库内容
expdp lambert_sss/xxxxxxx@localhost:1521/lambert schemas=lambert_sss dumpfile=expdp.dmp directory=dump_dir
impdp lambert_sss/xxxxxxx@localhost:1521/lambert directory=dump_dir dumpfile=expdp.dmp schemas=lambert_sss
impdp sss/xxxxxxx@localhost:1521/lambert directory=dump_dir dumpfile=expdp.dmp remap_schema=lambert_sss:sss table_exists_action=replace

 

posted @ 2017-11-30 09:42  零零柒  阅读(188)  评论(0编辑  收藏  举报