数据表空间

数据库表空间

一个数据库有多个表空间
表空间包含多个数据文件
表空间:永久表空间、临时表空间、UNDO表空间(撤销操作)

查看用户登录表空间

低权限用户不可查看高权限用户的表空间

数据字典:

desc dba_tablespaces(system的表空间、高权限)\ desc user_tablespaces(用户表空间、低权限、不可查询dba的表空间)

查看默认表空间/临时表空间:

select default_tablespace, temporary_tablespace from dba_users where username='SYSTEM';

创建表空间

创建永久表空间:

create tablespace test1_tablespace
tempfile 'tempfile1.dbf' size 10m;

创建临时表空间:

create temporary tablespace temptest1_tablespace
tempfile 'tempfile1.dba' size 10m;

查看永久表空间:

desc dba_data_files

查看临时表空间:

desc dba_temp_files

选择永久表空间:

select file_name from dba_data_files where tablespace_name='TEST1_TABLESPACE';

选择临时表空间:

select file_name from dba_temp_files where tablespace_name='TEMPTEST1_TABLESPACE';

修改表空间

修改查看表空间状态

设置表空间状态:

alter tablespace test1_tablespace
online;或者offline;

设置只读/读写状态的表空间

alter tablespace test1_tablespace
read only;或者read write;

查看表空间状态:
desc dba_tablespaces

得到表空间列表后:

select status from dba_tablespaces where tablespace_name='TEST1_TABLESPACE';

增加修改表空间的数据文件

增加数据文件:

alter tablespace test1_tablespace
add datafile 'test2_file.dbf' size 10m;//在表空间test1_tablespace中添加大小为10m的test2_file.dbf文件

查询文件名:

select from dba_data_files where tablespace_name='TEST1_TABLESPACE';

删除数据文件(不能删除表空间的第一个数据文件)

alter tablespace test1_tablespace
drop datafile 'test2_file.dbf';

删除表空间

1.只删除表空间不删除里面的文件数据:

drop tablespace test1_tablespace 

2.既删除表空间又删除里面的文件数据:

drop tablespace test1_tablespace including contents(目录名字);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值