1. 程式人生 > >17.08.07

17.08.07

example block toe blocks lar files 自己 修改 esc

查詢預定義表空間:

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