'분류 전체보기'에 해당되는 글 112건
- 2009.02.18 [ORACLE] External table
- 2009.02.12 [ORACLE] Full Hint Naming Convention - Dion Cho
- 2009.02.11 [ORACLE] Partition
- 2009.02.09 [ORACLE] Manage Indexes
- 2009.02.06 [ORACLE] Calcurate Unformatted rate, Unformatted size
- 2009.02.06 [ORACLE] dbms_xplan reference - 10g (ing)
- 2009.02.05 [ORACLE] dbms_space - space_usage
- 2009.02.04 [ORACLE] dbms_stats - Table
- 2009.01.26 ORACLE - index_stats
- 2009.01.21 ORACLE에서 시간차 구하는 여러가지 방법
1. Make directory
create directory [dir_nm] as '[dir_path]';2. Make table
create table [table_name] ( column1 char(10) ,column2 char(10) ) organization external ( type oracle_loader default directory [dir_nm] access parameters( records delimited by newline fields terminated by ';'( column1 char, column2 char)) location('[file_name]')) ;
How to find full hint naming.
Possible Above 10g R2 (maybe)
select * from table(dbms_xplan.display(null, null, 'outline'));
How to use it.
- sample
FULL(@"SEL$1_2" "T1"@"SEL$1_2")
FULL(@"SEL$1_1" "T1"@"SEL$1")
즉 FULL Hint의 Full Naming Convention은 다음과 같다.
FULL(@query_block_name table_alias_name)
FULL(@"SEL$1_1" "T1"@"SEL$1")
INDEX(@"SEL$1_2" "T1"@"SEL$1_2" ("T1"."C1")) */
This post have a trackback.
http://ukja.tistory.com/trackback/163
Range Partition
- Create Table
CREATE TABLE TABLE_NAME ( COLUMN_1 DATE ,COLUMN_2 VARCHAR2(X) ) TABLESPACE XXX PCTUSED 0 PCTFREE 0 INITRANS 1 MAXTRANS 255 STORAGE ( INITIAL 5M NEXT 10M MINEXTENTS 1 MAXEXTENTS UNLIMITED PCTINCREASE 0 BUFFER_POOL DEFAULT ) NOLOGGING COMPRESS NOCACHE NOPARALLEL NOMONITORING PARTITION BY RANGE(COLUMN_1) ( PARTITION PAR_MIN VALUES LESS THAN (TO_DATE('2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')) ,PARTITION PAR_MAX VALUES LESS THAN (TO_DATE('9999-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')) );
- Alter table (Partition)
ADD (HASH), COALESCE (HASH), DROP,
EXCHANGE, MERGE, MOVE, SPLIT, TRUNCATE
alter table table_name exchange partition partition_name with table table_name with validation;
1. Add/Drop/Truncate Partition
alter table table_name add partition partition_name values less than ('value'); alter table table_name drop partition partition_name; alter table table_name truncate partition partition_name;/
2. Else
split
alter table table_name split partition partition_name at ('20090301') into (partition par_200902, partition par_max) parallel 8;
Coalesce
Global Index
Partitioned Index
Rebuild
Global Index & Partitioned Index
Global Index
alter index [index_owner].[index_name] coalesce;
Partitioned Index
alter index [index_owner].[index_name] modify partition [partition_name] coalesce;
Rebuild
Global Index & Partitioned Index
alter index [index_owner].[index_name] rebuild partition [partition_name];
[dbms_xplan]
- Display (Oracle 9i ~)
---------------------------------------------------------
DBMS_XPLAN.DISPLAY(
table_name IN VARCHAR2 DEFAULT 'PLAN_TABLE',
statement_id IN VARCHAR2 DEFAULT NULL,
format IN VARCHAR2 DEFAULT 'TYPICAL',
filter_preds IN VARCHAR2 DEFAULT NULL);
---------------------------------------------------------
---------------------------------------------------------
Usage
---------------------------------------------------------
---------------------------------------------------------
- Display (Oracle 9i ~)
---------------------------------------------------------
DBMS_XPLAN.DISPLAY(
table_name IN VARCHAR2 DEFAULT 'PLAN_TABLE',
statement_id IN VARCHAR2 DEFAULT NULL,
format IN VARCHAR2 DEFAULT 'TYPICAL',
filter_preds IN VARCHAR2 DEFAULT NULL);
---------------------------------------------------------
---------------------------------------------------------
Usage
---------------------------------------------------------
explan plan for [sql];
select * from table(dbms_xplan.display);
---------------------------------------------------------
set serveroutput on declare l_fs1_bytes number; l_fs2_bytes number; l_fs3_bytes number; l_fs4_bytes number; l_fs1_blocks number; l_fs2_blocks number; l_fs3_blocks number; l_fs4_blocks number; l_full_bytes number; l_full_blocks number; l_unformatted_bytes number; l_unformatted_blocks number; begin dbms_space.space_usage( segment_owner => '&&owner', segment_name => '&&name', segment_type => 'TABLE', fs1_bytes => l_fs1_bytes, fs1_blocks => l_fs1_blocks, fs2_bytes => l_fs2_bytes, fs2_blocks => l_fs2_blocks, fs3_bytes => l_fs3_bytes, fs3_blocks => l_fs3_blocks, fs4_bytes => l_fs4_bytes, fs4_blocks => l_fs4_blocks, full_bytes => l_full_bytes, full_blocks => l_full_blocks, unformatted_blocks => l_unformatted_blocks, unformatted_bytes => l_unformatted_bytes ); dbms_output.put_line(' FS1 Blocks = '||l_fs1_blocks||' Bytes = '||l_fs1_bytes); dbms_output.put_line(' FS2 Blocks = '||l_fs2_blocks||' Bytes = '||l_fs2_bytes); dbms_output.put_line(' FS3 Blocks = '||l_fs3_blocks||' Bytes = '||l_fs3_bytes); dbms_output.put_line(' FS4 Blocks = '||l_fs4_blocks||' Bytes = '||l_fs4_bytes); dbms_output.put_line('Full Blocks = '||l_full_blocks||' Bytes = '||l_full_bytes); dbms_output.put_line('Unformatted Blocks = '||l_unformatted_blocks||' Bytes = '||l_unformatted_bytes); end; / set serveroutput off
Gather information about all columns
Gather information about indexed columns
exec dbms_stats.gather_table_stats ( - '&&owner', '&&table_name' - ,estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE - ,block_sample => true - ,granularity => 'all' - ,method_opt => 'for all columns size auto' - ,cascade => true)
Gather information about indexed columns
exec dbms_stats.gather_table_stats ( - '&&owner', '&&table_name' - ,estimate_percent => DBMS_STATS.AUTO_SAMPLE_SIZE - ,block_sample => true - ,granularity => 'all' - ,method_opt => 'for all indexed columns size auto' - ,cascade => true)
analyze index [INDEX_NAME] validate structure; select * from index_stats ;
숫자로 된 시간데이터를 HH24:MI:SS 형식으로 변경 할 때
2개의 datetype으로 된 시간의 차를 계산 할 때
,to_char(floor(avg_time*24)) hour ,to_char(case when floor(avg_time*24*60) >= 60 then (floor(avg_time*24*60)-(floor(avg_time*24)*60)) else floor(avg_time*24*60) end ) min ,to_char(floor(((avg_time*24*60)-floor(avg_time*24*60))*60)) sec
select to_char(to_date(round((sysdate-(sysdate-1/24/60*5))*24*60),'sssss'),'hh24:mi:ss') from dual;
2개의 datetype으로 된 시간의 차를 계산 할 때
substr(to_timestamp(to_char(end_date,'YYYYMMDDHH24MISS'),'YYYYMMDDHH24MISS') - to_timestamp(to_char(start_date,'YYYYMMDDHH24MISS'),'YYYYMMDDHH24MISS'),12,8) as time_between