表空间
--表空间
CREATE TABLESPACE RY_TS
DATAFILE 'c:\\ts\\RY.dbf'
SIZE 3000m
AUTOEXTEND ON
NEXT 100m;
创建用户
--创建用户
create user ry--用户
identified by ry--密码
default tablespace RY_TS;
授权
--授权
grant dba to ry;
查看表空间的名字及文件所在位置
select tablespace_name,
file_id,
file_name,
round(bytes / (1024 * 1024), 0) total_space
from sys.dba_data_files
order by tablespace_name
查询表空间信息
select username,default_tablespace,t.* from dba_users t
查询当前表空间下使用情况
select a.tablespace_name,
a.bytes / 1024 / 1024 "sum MB",
(a.bytes - b.bytes) / 1024 / 1024 "used MB",
b.bytes / 1024 / 1024 "free MB",
round(((a.bytes - b.bytes) / a.bytes) * 100, 2) "used%"
from (select tablespace_name, sum(bytes) bytes
from dba_data_files
group by tablespace_name) a,
(select tablespace_name, sum(bytes) bytes, max(bytes) largest
from dba_free_space
group by tablespace_name) b
where a.tablespace_name = b.tablespace_name
order by ((a.bytes - b.bytes) / a.bytes) desc;

增加表空间语句,这条语句中的
users:表空间名称
单引号中间的是新文件的路径
20000m表示表空间的大小
100m表示下次自动扩充是100m一次
ALTER tablespace users add datafile '/u01/app/oracle/oradata/orcl/users02.dbf'
size 20000m AUTOEXTEND ON NEXT 100m;
我这里加了20G,时间有点久,稍微等待一下就好,给空间小就会快一点
本文详细介绍了在Oracle数据库中创建表空间、用户及授权的过程。包括表空间的创建语句、用户创建与默认表空间设置,以及如何进行授权。此外,还提供了查询表空间信息、使用情况的方法,以及如何增加表空间大小的示例。
462

被折叠的 条评论
为什么被折叠?



