|
- select substr(t.table_name,3,1),count(*) from dba_tables t where t.tablespace_name='SYSAUX'
- and t.table_name like 'WR_$\_%' escape '\'
- group by substr(t.table_name,3,1);
复制代码
基线和自适应告警:
优化器统计信息:
- select t.num_rows ,t.table_name
- from dba_tables t
- where t.owner='HR' and t.table_name in ('T04209_UNAME','T_BIG');
-
- begin
- dbms_stats.gather_table_stats(ownname => 'HR',
- tabname => 'T04209_UNAME');
- end;
-
- select t.num_rows ,t.table_name
- from dba_tables t
- where t.owner='HR' and t.table_name in ('T04209_UNAME','T_BIG');
-
- begin
- dbms_stats.gather_table_stats(ownname => 'HR',
- tabname => 'T_BIG');
- end;
-
-
- select * from dba_tab_col_statistics tcs
- where tcs.owner='HR' and tcs.table_name='T_BIG';
-
- begin
- dbms_stats.gather_table_stats(ownname => 'HR',
- tabname => 'T_BIG',
- method_opt=>'for columns type size 9 for all columns size auto');
- end;
-
- select * from dba_tab_col_statistics tcs
- where tcs.owner='HR' and tcs.table_name='T_BIG';
-
-
- begin
- dbms_stats.gather_table_stats(ownname => 'HR',
- tabname => 'T_BIG',
- method_opt=>'for columns type size 9 for all columns size auto',
- estimate_percent=> dbms_stats.auto_sample_size);
- end;
-
- begin
- dbms_stats.gather_table_stats(ownname => 'HR',
- tabname => 'T_BIG',
- method_opt=>'for columns type size 9 for all columns size auto',
- estimate_percent=> 100);
- end;
-
- begin
- dbms_stats.gather_table_stats(ownname => 'HR',
- tabname => 'T_BIG',
- method_opt=>'for all columns size auto',
- estimate_percent=> 100);
- end;
复制代码
个性收集dbms_stats.gather_database_stats/dbms_stats.gather_schema_stats
- select dbms_stats.get_prefs(pname => 'STALE_PERCENT')
- from dual;
-
- begin
- dbms_stats.set_table_prefs(ownname => 'HR',tabname => 'T_BIG',
- pname => 'STALE_PERCENT',pvalue => 13);
- end;
-
- select dbms_stats.get_prefs(pname => 'STALE_PERCENT',ownname => 'HR',
- tabname => 'T_BIG')
- from dual;
-
- select * from dba_tab_stat_prefs;
复制代码 设置pending stats:
- select dbms_stats.get_prefs(pname => 'PUBLISH')
- from dual;
-
- select * from dba_tab_pending_stats;
-
- begin
- dbms_stats.set_table_prefs(ownname => 'HR',tabname => 'T_BIG',
- pname => 'PUBLISH',pvalue => 'FALSE');
- end;
-
- select dbms_stats.get_prefs(pname => 'PUBLISH',ownname => 'HR',
- tabname => 'T_BIG')
- from dual;
-
- select * from dba_tab_stat_prefs;
-
- begin
- dbms_Stats.gather_table_stats('HR','T_BIG');
- end;
-
- select * from dba_tab_pending_stats;
-
- begin
- dbms_stats.publish_pending_stats(ownname => 'HR',
- tabname => 'T_BIG');
- end;
复制代码
SQL Access Advisor快速调优通道:
- SQL> conn / as sysdba
- Connected.
- SQL> select type , count(*) from hr.t_big
- 2 group by type;
- TYPE COUNT(*)
- ------------ ----------
- PROCEDURE 10151
- PACKAGE 228607
- PACKAGE BODY 344031
- LIBRARY 189
- TYPE BODY 3903
- TRIGGER 18708
- FUNCTION 1955
- JAVA SOURCE 68
- TYPE 25575
- 9 rows selected.
- SQL>
复制代码- select * from dba_indexes i
- where i.table_owner='HR' and i.table_name='T_BIG';
-
- select t.num_rows ,t.last_analyzed from dba_tables t
- where t.owner='HR' and t.table_name='T_BIG';
- begin
- dbms_advisor.quick_tune(advisor_name => 'SQL Access Advisor',
- task_name => 'MYQ1',attr1 => 'select type , count(*) from hr.t_big group by type',
- template => 'SQLACCESS_OLTP');
- end;
-
- begin
- dbms_advisor.quick_tune(advisor_name => 'SQL Access Advisor',
- task_name => 'MYQ2',attr1 => 'select type , count(*) from hr.t_big group by type',
- template => 'SQLACCESS_WAREHOUSE');
- end;
复制代码
- select * from dba_Tables t
- where t.tablespace_name='TBSUTF8_11G';
-
- insert into hr.TUTF8_11G select * from hr.TUTF8_11G where rownum < 100000;
-
- select count(*) from hr.TUTF8_11G;
-
- select * from dba_outstanding_alerts;
-
- select * from dba_alert_history ah
- order by ah.time_suggested desc;
-
- truncate table hr.tutf8_11g;
复制代码- declare
- v1 number;
- begin
- dbms_application_info.set_module(module_name=>'AP',action_name=>'APACTION');
- select count(*) into v1 from t_big a , t_big b;
- end;
- /
复制代码
-
- select s.HASH_VALUE , s.ADDRESS from v_$sql s ;
-
- begin
- dbms_shared_pool.keep('00000001D1E4D160,70647824','C');
- end;
复制代码
PGA使用直方图(0趟,1趟,多趟)
- select * from V$PGA_TARGET_ADVICE_HISTOGRAM;
复制代码
- select * from V$SYS_TIME_MODEL;
- select * from V$SYSTEM_WAIT_CLASS;
复制代码
图形界面上的快照在哪里?
- select * from dba_hist_ash_snapshot;
- select * from dba_hist_snapshot;
复制代码- [root@station90 ~]# su - oracle
- [oracle@station90 ~]$ sqlplus /nolog
- SQL*Plus: Release 11.2.0.1.0 Production on Sat May 30 15:13:48 2015
- Copyright (c) 1982, 2009, Oracle. All rights reserved.
- SQL> conn hr/oracle_4U
- ERROR:
- ORA-28002: the password will expire within 5 days
- Connected.
- SQL> create table t05318_chain(a varchar2(2000), b varchar2(2000), c varchar2(2000), d varchar2(2000));
- Table created.
- SQL> insert into t05318_chain(a) values('aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> select dbms_rowid.rowid_block_number ( rowid ) from t05318_chain;
- DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
- ------------------------------------
- 559
- SQL> select * from CHAINED_ROWS;
- select * from CHAINED_ROWS
- *
- ERROR at line 1:
- ORA-00942: table or view does not exist
- SQL> @?/rdbms/admin/utlchain.sql
- Table created.
- SQL> set linesize 1000
- SQL> select * from CHAINED_ROWS;
- no rows selected
- SQL> analyze table t05318_chain list chained rows;
- Table analyzed.
- SQL> select * from CHAINED_ROWS;
- no rows selected
- SQL> update t05318_chain set d='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa';
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> select dbms_rowid.rowid_block_number ( rowid ) from t05318_chain;
- DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID)
- ------------------------------------
- 559
- SQL> analyze table t05318_chain list chained rows;
- Table analyzed.
- SQL> select * from CHAINED_ROWS;
- OWNER_NAME TABLE_NAME CLUSTER_NAME PARTITION_NAME SUBPARTITION_NAME HEAD_ROWID ANALYZE_TIMESTAMP
- ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------ ------------------
- HR T05318_CHAIN N/A AAASOPAAEAAAAIvAAA 30-MAY-15
- SQL> truncate table CHAINED_ROWS;
- Table truncated.
- SQL> select * from CHAINED_ROWS;
- no rows selected
- SQL> analyze table t05318_chain list chained rows;
- Table analyzed.
- SQL> select * from CHAINED_ROWS;
- OWNER_NAME TABLE_NAME CLUSTER_NAME PARTITION_NAME SUBPARTITION_NAME HEAD_ROWID ANALYZE_TIMESTAMP
- ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------ ------------------
- HR T05318_CHAIN N/A AAASOPAAEAAAAIvAAA 30-MAY-15
- SQL> truncate table CHAINED_ROWS;
- Table truncated.
- SQL> select * from CHAINED_ROWS;
- no rows selected
- SQL> alter table t05318_chain move tablspace tbs16k;
- alter table t05318_chain move tablspace tbs16k
- *
- ERROR at line 1:
- ORA-14133: ALTER TABLE MOVE cannot be combined with other operations
- SQL> alter table t05318_chain move tablespace tbs16k;
- Table altered.
- SQL> analyze table t05318_chain list chained rows;
- Table analyzed.
- SQL> select * from CHAINED_ROWS;
- no rows selected
- SQL> create table t05318_migrate( a varchar2(2000)) pctfree 0;
- Table created.
- SQL> show user
- USER is "HR"
- begin
- for i in 1..733
- loop
- insert into t05318_migrate values('A');
- end loop;
- commit;
- 7 end;
- 8 /
- PL/SQL procedure successfully completed.
- SQL> select dbms_rowid.rowid_block_number(rowid) , count(*) from t05318_migrate
- 2 group by dbms_rowid.rowid_block_number(rowid);
- DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) COUNT(*)
- ------------------------------------ ----------
- 559 733
- SQL> begin
- 2 for i in 1..100
- 3 loop
- 4 insert into t05318_migrate values('B');
- 5 end loop;
- 6 commit;
- 7 end;
- 8 /
- PL/SQL procedure successfully completed.
- SQL> select dbms_rowid.rowid_block_number(rowid) , count(*) from t05318_migrate
- 2 group by dbms_rowid.rowid_block_number(rowid);
- DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) COUNT(*)
- ------------------------------------ ----------
- 555 100
- 559 733
- SQL> delete from t05318_migrate where A='B';
- 100 rows deleted.
- SQL> commit;
- Commit complete.
- SQL> select dbms_rowid.rowid_block_number(rowid) , count(*) from t05318_migrate
- 2 group by dbms_rowid.rowid_block_number(rowid);
- DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) COUNT(*)
- ------------------------------------ ----------
- 559 733
- SQL> analyze table t05318_migrate list chained rows;
- Table analyzed.
- SQL> select * from chained_rows;
- no rows selected
- SQL> update t05318_migrate set a=''aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa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aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa' where rownum=1;
- 1 row updated.
- SQL> commit;
- Commit complete.
- SQL> analyze table t05318_migrate list chained rows;
- Table analyzed.
- SQL> select * from chained_rows;
- OWNER_NAME TABLE_NAME CLUSTER_NAME PARTITION_NAME SUBPARTITION_NAME HEAD_ROWID ANALYZE_TIMESTAMP
- ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------------------ ------------------ ------------------
- HR T05318_MIGRATE N/A AAASOUAAEAAAAIvAAA 30-MAY-15
- SQL> select dbms_rowid.rowid_block_number(rowid) , count(*) from t05318_migrate
- 2 group by dbms_rowid.rowid_block_number(rowid);
- DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) COUNT(*)
- ------------------------------------ ----------
- 559 733
- SQL> alter table T05318_MIGRATE move tablespace users;
- Table altered.
- SQL> select dbms_rowid.rowid_block_number(rowid) , count(*) from t05318_migrate
- 2 group by dbms_rowid.rowid_block_number(rowid);
- DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) COUNT(*)
- ------------------------------------ ----------
- 588 185
- 587 548
- SQL> alter table T05318_MIGRATE pctfree 20;
- Table altered.
- SQL> alter table T05318_MIGRATE move tablespace users;
- Table altered.
- SQL> select dbms_rowid.rowid_block_number(rowid) , count(*) from t05318_migrate
- 2 group by dbms_rowid.rowid_block_number(rowid);
- DBMS_ROWID.ROWID_BLOCK_NUMBER(ROWID) COUNT(*)
- ------------------------------------ ----------
- 555 402
- 556 331
- SQL> truncate table chained_rows;
- Table truncated.
- SQL> analyze table T05318_MIGRATE list chained rows;
- Table analyzed.
- SQL> select * from chained_rows;
- no rows selected
- SQL>
复制代码- Oracle11gR2的表压缩特性通过压缩表中的数据以减少对空间的占用。Oracle11gR2支持三种不同的压缩方式:
- · 支持直接路径加载的Basic压缩方式(10x)
- · 支持针对所有DML操作的OLTP压缩方式(2-4x)
- · Exadata专属的Hybrid columnar compression压缩方式
- Oracle公司建议我们采用以上三种不同的压缩方式,针对特定的应用场合来进行表压缩。如果该表包含大量冗长的和重复的值,通过被压缩可以减少该表对磁盘空间的占用和对SGA中数据库缓冲区缓存的占用。
- 先从图形界面入手,我们发现在新建表空间时Oracle11gR2的界面出现压缩选项:
- 在 下面各个部分所有的实验中我们都创建两个表:一个表在TBS_NOCOMPRESSION表空间,另一个表在有对应默认压缩选项的表空间。最后我们把在 TBS_NOCOMPRESSION表空间上的那个表转换成对应压缩选项表。通过对比实验来弄清Oracle11gR2这方面的新特性。
- --sys--
- create tablespace tbs_nocompression datafile size 10M autoextend on;
- create tablespace tbs_basic datafile size 10M autoextend on default compress basic;
- create tablespace tbs_oltp datafile size 10M autoextend on default compress for oltp;
- create tablespace tbs_query datafile size 10M autoextend on default compress for query;
- create tablespace tbs_archive datafile size 10M autoextend on default compress for archive;
- select t.tablespace_name, t.def_tab_compression, t.compress_for from dba_tablespaces t
- where t.tablespace_name in ('TBS_NOCOMPRESSION',
- 'TBS_BASIC', 'TBS_OLTP',
- 'TBS_QUERY',
- 'TBS_ARCHIVE');
- --hr--
- create table t_nocompression (a varchar2(200)) tablespace tbs_nocompression;
- create table t_basic (a varchar2(200)) tablespace tbs_basic;
- create table t_oltp (a varchar2(200)) tablespace tbs_oltp;
- --hr-error--
- create table t_query (a varchar2(200)) tablespace tbs_query;
- create table t_archive (a varchar2(200)) tablespace tbs_archive;
- --hr--
- begin
- for i in 1..400
- loop
- insert into t_nocompression values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end;
- --hr--
- begin
- for i in 1..400
- loop
- insert into t_basic values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end;
- --hr--
- begin
- for i in 1..400
- loop
- insert into t_oltp values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end;
- --hr--
- select t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
- from user_tables t where t.TABLE_NAME in ('T_NOCOMPRESSION','T_BASIC','T_OLTP');
- select count(*) , substr(rowid, 10, 6 ) from hr.t_nocompression group by substr(rowid, 10, 6 );
- select count(*) , substr(rowid, 10, 6 ) from hr.t_basic group by substr(rowid, 10, 6 );
- select count(*) , substr(rowid, 10, 6 ) from hr.t_oltp group by substr(rowid, 10, 6 );
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
- from hr.T_NOCOMPRESSION group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
- from hr.T_BASIC group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP',row_id => rowid)
- from hr.T_OLTP group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP',row_id => rowid);
- --hr--
- create table t_basic2 (a varchar2(200)) tablespace tbs_nocompression compress;
- create table t_oltp2 (a varchar2(200)) tablespace tbs_nocompression compress for oltp;
- --hr-error--
- create table t_query2 (a varchar2(200)) tablespace tbs_nocompression compress for query;
- create table t_archive2 (a varchar2(200)) tablespace tbs_nocompression compress for archive;
- --hr--
- select t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
- from user_tables t where t.TABLE_NAME in ('T_NOCOMPRESSION','T_BASIC','T_OLTP', 'T_BASIC2','T_OLTP2' );
- --hr--
- begin
- for i in 1..400
- loop
- insert into t_basic2 values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end;
- --hr--
- begin
- for i in 1..400
- loop
- insert into t_oltp2 values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end;
- --hr--
- select count(*) , substr(rowid, 10, 6 ) from hr.t_basic2 group by substr(rowid, 10, 6 );
- select count(*) , substr(rowid, 10, 6 ) from hr.t_oltp2 group by substr(rowid, 10, 6 );
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC2',row_id => rowid)
- from hr.T_BASIC2 group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC2',row_id => rowid);
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP2',row_id => rowid)
- from hr.T_OLTP2 group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_OLTP2',row_id => rowid);
- --hr--
- alter table t_nocompression compress for oltp;
- select t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
- from user_tables t where t.TABLE_NAME in ('T_NOCOMPRESSION','T_BASIC','T_OLTP', 'T_BASIC2','T_OLTP2' );
- select count(*) , substr(rowid, 10, 6 ) from hr.t_nocompression group by substr(rowid, 10, 6 );
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
- from hr.T_NOCOMPRESSION group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
- --hr--
- begin
- for i in 1..400
- loop
- insert into t_nocompression values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end;
- --hr--
- select count(*) , substr(rowid, 10, 6 ) from hr.t_nocompression group by substr(rowid, 10, 6 );
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
- from hr.T_NOCOMPRESSION group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
- --hr--
- alter table t_nocompression move tablespace tbs_nocompression;
- select count(*) , substr(rowid, 10, 6 ) from hr.t_nocompression group by substr(rowid, 10, 6 );
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid)
- from hr.T_NOCOMPRESSION group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_NOCOMPRESSION',row_id => rowid);
- --hr--
- select count(*) , substr(rowid, 10, 6 ) from hr.t_basic group by substr(rowid, 10, 6 );
- insert /*+ append */ into t_basic select * from t_basic;
- commit;
- select count(*) , substr(rowid, 10, 6 ) from hr.t_basic group by substr(rowid, 10, 6 );
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
- from hr.T_BASIC group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
- --hr--
- alter table t_basic move tablespace TBS_NOCOMPRESSION;
- select count(*) , substr(rowid, 10, 6 ) from hr.t_basic group by substr(rowid, 10, 6 );
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid)
- from hr.T_BASIC group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC',row_id => rowid);
- --sys-evolution--
- drop table hr.t_basic_big;
- create table hr.t_basic_big compress as select * from dba_source;
- --sys-advisor--
- declare
- v_blkcnt_cmp number;
- v_blkcnt_uncmp number;
- v_row_cmp number;
- v_row_uncmp number;
- v_cmp_ratio number;
- v_comptype_str varchar2(200);
- BEGIN
- DBMS_COMPRESSION.GET_COMPRESSION_RATIO(scratchtbsname => 'USERS',
- ownname =>'HR',
- tabname =>'T_BASIC_BIG',
- partname =>null,
- comptype => 2,
- blkcnt_cmp => v_blkcnt_cmp,
- blkcnt_uncmp => v_blkcnt_uncmp,
- row_cmp =>v_row_cmp,
- row_uncmp => v_row_uncmp,
- cmp_ratio => v_cmp_ratio,
- comptype_str =>v_comptype_str);
- DBMS_OUTPUT.PUT_LINE('Blk count compressed = ' || v_blkcnt_cmp);
- DBMS_OUTPUT.PUT_LINE('Blk count uncompressed = ' || v_blkcnt_uncmp);
- DBMS_OUTPUT.PUT_LINE('Row count per block compressed = ' || v_row_cmp);
- DBMS_OUTPUT.PUT_LINE('Row count per block uncompressed = ' || v_row_uncmp);
- DBMS_OUTPUT.PUT_LINE('ratio: '||v_cmp_ratio);
- DBMS_OUTPUT.PUT_LINE('Compression type = ' || v_comptype_str);
- end;
- --输出--
- Blk count compressed = 1785
- Blk count uncompressed = 2340
- Row count per block compressed = 68
- Row count per block uncompressed = 51
- ratio: 1.31092436974789915966386554621848739496
- Compression type = "Compress For OLTP"
- --OLTP压缩一下表--
- 验证表大小
- --sys--
- select count(*) , dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC_BIG',row_id => rowid)
- from hr.T_BASIC_BIG group by dbms_compression.get_compression_type(ownname => 'HR',tabname => 'T_BASIC_BIG',row_id => rowid);
- --hr--
- create table t_basic_col( a number , b varchar2(20)) compress ;
- insert into t_basic_col values ( 1,'A') ;
- commit;
- create table t_oltp_col( a number , b varchar2(20)) compress for oltp;
- insert into t_oltp_col values ( 1,'A') ;
- commit;
- select * from t_basic_col;
- select * from t_oltp_col;
- alter table t_basic_col drop column b;
- alter table t_basic_col drop ( b);
- alter table t_oltp_col drop column b;
- select * from t_oltp_col;
复制代码
- create or replace trigger trgocp11_limit
- after suspend
- on database
- declare
- v_size number;
- pragma AUTONOMOUS_TRANSACTION;
- begin
- select BYTES into v_size from dba_data_files where FILE_ID=10;
- execute immediate 'alter database datafile 10 resize '||to_char(v_size+10485760);
- commit;
- end;
复制代码
|
|