|
上完1Z0-053第15章,开始1Z0-053第18章
1Z0-052共19章(上完19章),1Z0-053共21章(上完20章)和1Z0-063多租户部分共9章(上完0章)
总共上完全部49章中的39章
行迁移与行链接:
行迁移:
不可用索引,没有段:
- SQL> conn / as sysdba
- Connected.
- SQL> show parameter deffer
- SQL> show parameter defer
- NAME TYPE VALUE
- ------------------------------------ ----------- ------------------------------
- deferred_segment_creation boolean TRUE
- SQL> !clear
- SQL> conn hr/oracle_4U
- Connected.
- SQL> create table tpart1 ( a number , b varchar2(20))
- 2 partition by range (a)
- 3 (
- 4 partition p1 values less than (100),
- 5 partition p2 values less than (maxvalue) ) ;
- Table created.
- SQL> insert into tpart1 values (100,'A') ;
- 1 row created.
- SQL> insert into tpart1 values (1,'A') ;
- 1 row created.
- SQL>
复制代码
- select * from dba_segments s
- where s.SEGMENT_NAME='TPART1';
-
- select * from dba_indexes i
- where i.INDEX_NAME='IOT1_INDEX';
-
- select * from dba_segments s where s.SEGMENT_NAME
- in ('IOT1','IOT1_INDEX');
-
- select * from dba_Tables t
- where t.TABLE_NAME='IOT1';
复制代码- SQL> create index ipart1_a on tpart1(a) local ;
- Index created.
复制代码- SQL> alter table tpart1 move partition p1 tablespace example ;
- Table altered.
- SQL> alter index ipart1_a rebuild partition p1 ;
- Index altered.
复制代码- SELECT segment_name, partition_name, segment_type
- FROM dba_segments
- WHERE segment_name like '%PART1%';
复制代码 索引的压缩:
- SQL> conn hr/hr
- Connected.
- SQL> create table t1 ( a char(2000)) ;
- Table created.
- SQL> select bytes from user_segments where segment_name='T1';
- BYTES
- ----------
- 65536
- SQL> begin
- 2 for i in 1..1000
- 3 loop
- 4 insert into t1 values ( 'A');
- 5 end loop;
- 6 commit;
- 7 end;
- 8 /
- PL/SQL procedure successfully completed.
- SQL> select bytes from user_segments where segment_name='T1';
- BYTES
- ----------
- 3145728
- SQL> create index i1 on t1 (a) ;
- Index created.
- SQL> select bytes from user_segments where segment_name='I1';
- BYTES
- ----------
- 4194304
- SQL> drop index i1;
- Index dropped.
- SQL> create index i1 on t1 (a) compress;
- Index created.
- SQL> select bytes from user_segments where segment_name='I1';
- BYTES
- ----------
- 65536
复制代码- SQL> select index_name, index_type , COMPRESSION from user_indexes where index_name='I1';
- INDEX_NAME INDEX_TYPE COMPRESS
- ------------------------------ --------------------------- --------
- I1 NORMAL ENABLED
复制代码 表空间的默认压缩:
- SQL*Plus: Release 12.1.0.2.0 Production on Sat Jul 22 17:09:04 2017
- Copyright (c) 1982, 2014, Oracle. All rights reserved.
- SQL> conn / as sysdba
- Connected.
- SQL> create tablespace tbs_query datafile size 10M autoextend on default compress for query;
- create tablespace tbs_query datafile size 10M autoextend on default compress for query
- *
- ERROR at line 1:
- ORA-64307: Exadata Hybrid Columnar Compression is not supported for
- tablespaces on this storage type
- SQL> create tablespace tbs_archive datafile size 10M autoextend on default compress for archive;
- create tablespace tbs_archive datafile size 10M autoextend on default compress for archive
- *
- ERROR at line 1:
- ORA-64307: Exadata Hybrid Columnar Compression is not supported for
- tablespaces on this storage type
- SQL> !clear
- SQL> conn hr/oracle_4U
- Connected.
- SQL> create table t_nocompression (a varchar2(200)) tablespace tbs_nocompression;
- Table created.
- SQL> create table t_basic (a varchar2(200)) tablespace tbs_basic;
- Table created.
- SQL> create table t_oltp (a varchar2(200)) tablespace tbs_oltp;
- Table created.
- SQL> begin
- for i in 1..400
- loop
- insert into t_nocompression values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end; 2 3 4 5 6 7
- 8 /
- PL/SQL procedure successfully completed.
- SQL> begin
- for i in 1..400
- loop
- insert into t_basic values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end; 2 3 4 5 6 7
- 8 /
- PL/SQL procedure successfully completed.
- SQL> begin
- for i in 1..400
- loop
- insert into t_oltp values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end; 2 3 4 5 6 7
- 8 /
- PL/SQL procedure successfully completed.
复制代码- select t.tablespace_name,
- t.def_tab_compression,
- t.compress_for from dba_tablespaces t;
-
- 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');
-
- -----
- select t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
- from dba_tables t where t.TABLE_NAME in ('T_NOCOMPRESSION','T_BASIC','T_OLTP');
-
复制代码- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_nocompression group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 121 AAAACD
- 279 AAAACH
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_basic group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 90 AAAACD
- 310 AAAACH
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_oltp group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 400 AAAACH
复制代码- 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);
-
-
- 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) ;
-
- 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) ;
复制代码- SQL> create table t_basic2 (a varchar2(200)) tablespace tbs_nocompression compress;
- Table created.
- SQL> create table t_oltp2 (a varchar2(200)) tablespace tbs_nocompression compress for oltp;
- Table created.
- SQL> begin
- for i in 1..400
- loop
- insert into t_basic2 values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end; 2 3 4 5 6 7
- 8 /
- PL/SQL procedure successfully completed.
- SQL> begin
- for i in 1..400
- loop
- insert into t_oltp2 values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end; 2 3 4 5 6 7
- 8 /
- PL/SQL procedure successfully completed.
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_basic2 group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 310 AAAACP
- 90 AAAACL
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_oltp2 group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 400 AAAACX
- SQL>
复制代码- 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);
复制代码- SQL> alter table t_nocompression compress for oltp;
- Table altered.
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_nocompression group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 121 AAAACD
- 279 AAAACH
- SQL> begin
- for i in 1..400
- loop
- insert into t_nocompression values('AAAAAAAAAAAAAAAAAAAA');
- end loop;
- commit;
- end; 2 3 4 5 6 7
- 8 /
- PL/SQL procedure successfully completed.
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_nocompression group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 279 AAAACD
- 242 AAAACE
- 279 AAAACH
- SQL> alter table t_nocompression move tablespace tbs_nocompression;
- Table altered.
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_nocompression group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 148 AAAACc
- 652 AAAACb
- SQL>
复制代码- select t.TABLE_NAME, t.PCT_FREE , t.COMPRESSION , t.COMPRESS_FOR, t.TABLESPACE_NAME
- from dba_tables t where t.TABLE_NAME in ('T_NOCOMPRESSION','T_BASIC','T_OLTP');
- 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);
-
- ---
-
复制代码- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_basic group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 90 AAAACD
- 310 AAAACH
- SQL> insert /*+ append */ into t_basic select * from t_basic;
- 400 rows created.
- SQL> commit;
- Commit complete.
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_basic group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 400 AAAACI
- 90 AAAACD
- 310 AAAACH
- SQL> alter table t_basic move tablespace TBS_NOCOMPRESSION;
- Table altered.
- SQL> select count(*) , substr(rowid, 10, 6 ) from hr.t_basic group by substr(rowid, 10, 6 );
- COUNT(*) SUBSTR(ROWID,10,6)
- ---------- ------------------------
- 725 AAAACD
- 75 AAAACE
复制代码- 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);
复制代码- SQL> create table hr.t_basic_big compress as select * from dba_source;
- Table created.
复制代码
|
|