(学习笔记)Oracle表空间相关基本命令

1.对用户解锁加锁:

  语法——“alter user [用户名] account [unlock / lock]”

  例子:alter user scott account unlock; 

    unlock表示解锁,locak表示锁定

2.创建永久或临时表空间:

  语法——“create [temporary / null] tablespace 表空间名字 [tempfile / datafile] ' 表空间物理文件名.dbf ' size 文件大小M”

  永久表空间例子:create tablespace test_tablespace datafile 'test_tablespace.dbf' size 10M;

  临时表空间例子:create temporary tablespace test_temp_tablespace tempfile 'test_temp_tablespace.dbf' size 10M;

    临时表空间需要在tablespace前面加上temporary

3.更改表空间的状态:

  联机状态:语法——“alter tablespace 表空间名字 [offline / online]”

    offline表示设置为脱机,online表示为联机,默认值

  读写状态:语法——“alter tablespace 表空间的名字 [read only / read write]‘  

    read only表示为只读状态,read write表示为读写状态,默认值

  只能在联机状态下更改读写状态

4.向表空间添加删除数据文件:

  添加:语法——” alter tablespace 表空间的名字 add datafile ' 数据文件的名字.dbf ' size 文件大小M 

  删除:语法——” alter tablespace 表空间名字 drop datafile ' 数据文件的名字.dbf ' “

  创建表空间时生成的第一个数据文件不能删除

5.删除表空间

  语法——” drop tablespace 表空间名字 [including contents and datafiles / null] “

  加上including contents and datafiles 表示同时删除此表空间下的所有数据文件,不加表示只删除表空间,保留数据文件

猜你喜欢

转载自www.cnblogs.com/yemingqianduzou/p/9335622.html