码迷,mamicode.com
首页 > 其他好文 > 详细

17.08.07

时间:2017-08-19 11:04:17      阅读:212      评论:0      收藏:0      [点我收藏+]

标签:contents   byte   oracle   alt   extent   维护   修改   auto   .com   

 

查询预定义表空间:

 

SQL> select TABLESPACE_NAME,CONTENTS from dba_tablespaces;

 

SQL> select FILE_NAME, TABLESPACE_NAME from dba_data_files;

 

 

 

SYSTEM   系统表

 

SYSAUX   系统辅助表,不断变化

 

UNDOTBS1   撤销表空间,放撤销数据——修改之前的旧数据,是系统自动维护的(oracle 独有)

 

TEMP 临时表空间

 

USERS

 

EXAMPLE 

 

数据字典/动态性能视图

SQL> conn hr/hr

SQL> desc user_tables

SQL> select TABLE_NAME from user_tables;

SQL> desc user_views

SQL> select VIEW_NAME from user_views;

SQL> desc user_indexes

SQL> select INDEX_NAME, TABLE_NAME from user_indexes;

 

SQL> conn scott/tiger

SQL> select TABLE_NAME from user_tables;    user_表示用户自己的

SQL> select VIEW_NAME from user_views;

SQL> select INDEX_NAME, TABLE_NAME from user_indexes;

 

SQL> conn hr/hr

SQL> select count(*) from all_tables;     all_表示的是有权限访问的对象

 

SQL> conn scott/tiger

SQL> select count(*) from all_tables;

 

SQL> conn hr/hr

SQL> select count(*) from dba_tables;      

 

SQL> conn scott/tiger

SQL> select count(*) from dba_tables;

 

SQL> desc v$instance

SQL> desc v$database

 

Dml语句只能删除简单视图,无链接,运算等

 

以v$ 开头的动态性能视图

存储管理

技术分享

 

查询预定义表空间:

SQL> select TABLESPACE_NAME,CONTENTS from dba_tablespaces;

SQL> select FILE_NAME, TABLESPACE_NAME from dba_data_files;

 

SYSTEM   系统表

SYSAUX   系统辅助表,不断变化

UNDOTBS1   撤销表空间,放撤销数据——修改之前的旧数据,是系统自动维护的(oracle 独有)

TEMP 临时表空间

USERS

EXAMPLE 

 

创建新表空间:

SQL> create tablespace tbs01 datafile ‘/u01/app/oracle/oradata/orcl/tbs01.dbf‘ SIZE 10M AUTOEXTEND ON NEXT 10M MAXSIZE 100M;

在指定的表空间中创建表:

SQL> create table t1 tablespace tbs01 as select * from dba_objects where 1=0;

SQL> select bytes, blocks, extents, tablespace_name from dba_segments where segment_name=‘T1‘;

SQL> insert into t1 select * from dba_objects;

SQL> select bytes, blocks, extents, tablespace_name from dba_segments where segment_name=‘T1‘;

SQL> select extent_id, bytes, blocks from dba_extents where segment_name=‘T1‘;

SQL> insert into t1 select * from t1;

SQL> insert into t1 select * from t1;

SQL> insert into t1 select * from t1;

SQL> select bytes, blocks, extents, tablespace_name from dba_segments where segment_name=‘T1‘;

SQL> select extent_id, bytes, blocks from dba_extents where segment_name=‘T1‘;

SQL> insert into t1 select * from t1;                空间不足,报错

SQL> rollback;

SQL> select bytes, blocks, extents, tablespace_name from dba_segments where segment_name=‘T1‘;               空间不释放

SQL> alter table t1 move;        释放空间

只读表空间:

SQL> alter tablespace tbs01 read only;

SQL> delete t1;                 禁止dml

SQL> insert into t1 select * from t1;       禁止dml

SQL> create table t2 (x int) tablespace tbs01;        失败

SQL> alter table t1 add (x int);         成功

SQL> update t1 set x=1;          失败

SQL> drop table t1;          成功

dml和ddl的区别

改变表空间大小:

resize,autoextend,add datafile

删除表空间:

SQL> drop tablespace tbs01 including contents and datafile;

17.08.07

标签:contents   byte   oracle   alt   extent   维护   修改   auto   .com   

原文地址:http://www.cnblogs.com/Zhang-x/p/7395108.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!