oracle rac建表空间,Oracle创建表空间及在表空间下创建用户(oracle扩展RAC表空间)...

-- 查看所有数据文件路径以及对应的表空间名

select file_name , tablespace_name from dba_data_files;

SELECT

TABLE_NAME,

TABLESPACE_NAME

FROM

USER_TABLES

SELECT t.tablespace_name, round(SUM(bytes / (1024 * 1024)), 0) ts_size

FROM dba_tablespaces t, dba_data_files d

WHERE t.tablespace_name = d.tablespace_name

GROUP BY t.tablespace_name;

SELECT SUM(bytes) / (1024 * 1024) AS free_space, tablespace_name

FROM dba_free_space

GROUP BY tablespace_name;

SELECT a.tablespace_name,

a.bytes total,

b.bytes used,

c.bytes free,

(b.bytes * 100) / a.bytes "% USED ",

(c.bytes * 100) / a.bytes "% FREE "

FROM sys.sm$ts_avail a, sys.sm$ts_used b, sys.sm$ts_free c

WHERE a.tablespace_name = b.tablespace_name

AND a.tablespace_name = c.tablespace_name;

-- 查看所有表空间,总容量,剩余容量

SELECT tbs 表空间名,

sum(totalM) 总共大小M,

sum(usedM) 已使用空间M,

sum(remainedM) 剩余空间M,

sum(usedM)/sum(totalM)*100 已使用百分比,

sum(remainedM)/sum(totalM)*100 剩余百分比

FROM(

SELECT b.file_id ID,

b.tablespace_name tbs,

b.file_name name,

b.bytes/1024/1024 totalM,

(b.bytes-sum(nvl(a.bytes,0)))/1024/1024 usedM,

sum(nvl(a.bytes,0)/1024/1024) remainedM,

sum(nvl(a.bytes,0)/(b.bytes)*100),

(100 - (sum(nvl(a.bytes,0))/(b.bytes)*100))

FROM dba_free_space a,dba_data_files b

WHERE a.file_id = b.file_id

GROUP BY b.tablespace_name,b.file_name,b.file_id,b.bytes

ORDER BY b.tablespace_name

)

GROUP BY tbs

--创建新的表空间

create tablespace njdata datafile '+WLW_DATA1' size 28000m autoextend on next 100m maxsize 30000m extent management local segment space management auto;

--查看表空间数据文件

select file_name from dba_data_files where tablespace_name='NJDATA';

--扩展表空间

alter tablespace njdata add datafile '+WLW_DATA1' size 28000m autoextend on next 100m maxsize 30000m;

--查询当前用户所属表空间

select username,default_tablespace from user_users;

--创建用户、赋予权限

create user sdj identified by sdj ACCOUNT UNLOCK

DEFAULT TABLESPACE njdata TEMPORARY TABLESPACE TEMP;

grant connect to sdj;

grant resource to sdj;

GRANT CREATE USER,DROP USER,ALTER USER ,CREATE ANY VIEW ,DROP ANY VIEW,EXP_FULL_DATABASE,IMP_FULL_DATABASE,DBA,CONNECT,RESOURCE,CREATE SESSION TO sdj;

select count(*) from sdj.historydata

select * from sdj.historydata order by rtime desc

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值