oracle之表空间

一、dba_tablespaces和user_tablespaces两个数据字典

          1、dba_tablespaces:记录的是具有管理员权限的用户的表空间,需要登录具有管理员权限的用户才能访问:desc   dba_tablespaces

          2、user_tablespaces:记录的是普通用户的表空间,权限大于等于普通用户都可以访问:desc  user_tablespaces

二、dba_users和user_users两个数据字典

          1、dba_users:记录的是用户的信息,需要登录具有管理员权限的用户才能访问:desc   dba_users

          2、user_users:权限大于等于普通用户都可以访问:desc  user_users

三、dba_tables和user_tables两个数据字典

四、dba_constraints和user_constraints两个数据字典

五、设置用户的默认或者临时表空间,默认表空间也是永久表空间

          alert   user   username   default | temporary   tablespace    tablespace_name

          需要注意的是普通用户没有修改默认表空间和临时表空间的权限,需要赋予权限或者使用具有管理员权限的用户来为普通用户设置默认表空间和临时表空间

六、创建表空间

          create   [ temporary ]  tablespace    tablespace_name   tempfile |  datafile    ' xxx.dbf '     size     xx

         eg: create tablespace test1 datafile 'test1.dbf' size 10m;

                   create temporary tablespace temp1 tempfile 'temp1.dbf' size 5m;

          如果不加temporary则表示创建永久表空间 

七、dba_data_files和dba_temp_files 数据字典

           dba_data_files存储的是永久表空间数据文件( .dbf文件 )的信息: select file_name from dba_data_files where tablespace_name='TEST1';

           dba_temp_files存储的是临时表空间数据文件的信息: select file_name from dba_temp_files where tablespace_name='TEMP1';

           注意:tablespace_name后面引号中要大写

八、修改表空间

           1、修改表空间的状态

                      ①、 修改表空间的联机或脱机状态(默认是联机状态):alter   tablespace   tablespace_name   online | offline;

                      ②、设置表空间只读或可读写状态(默认是可读写状态,并且前提是处于联机状态):

alter  tablespace  tablespace_name  read only | read write;
alter tablespace test1 read only;

           2、查看表空间的状态:              

 select status from dba_tablespaces where tablespace_name='TEST1';
           3、修改表空间的数据文件

                    ①、向表空间中添加数据文件:

alter tablespace tablespace_name add datafile | tempfile  'xxx.dbf' size xx;
                    ②、删除数据文件(不能删除第一个创建的数据文件,如果要删除第一个数据文件,则需要删除表空间)

alter tablespace tablespace_name drop datafile | tempfile  'xxx.dbf';
            4、删除表空间(如果不加 including contents 则删除表空间的时候不会删除数据文件,加上则会删除数据文件):

drop tablespace tablespace_name [ including contents ]



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值