|
Skillset 3:
Section 8:
numyminterval()和numtodsinterval()这两个函数就是用来产生时间间隔:
- create table sh.sales_history_2006_2(
- PROD_ID NUMBER NOT NULL,
- CUST_ID NUMBER NOT NULL,
- TIME_ID DATE NOT NULL,
- CHANNEL_ID NUMBER NOT NULL,
- PROMO_ID NUMBER NOT NULL,
- QUANTITY_SOLD NUMBER(10,2) NOT NULL,
- AMOUNT_SOLD NUMBER(10,2) NOT NULL
- )
- partition by range (time_id)
- interval(numtodsinterval(1,'MINUTE'))
- (
- partition sal1 values less than (to_date('2003-01-01','YYYY-MM-DD')) tablespace SALES_TBS1,
- partition sal2 values less than (to_date('2004-01-01','YYYY-MM-DD')) tablespace SALES_TBS2,
- partition sal3 values less than (to_date('2005-01-01','YYYY-MM-DD')) tablespace SALES_TBS3,
- partition sal4 values less than (to_date('2006-01-01','YYYY-MM-DD')) tablespace SALES_TBS4
- );
复制代码- select * from dba_tables t
- where t.owner='SH' and t.table_name='SALES_HISTORY_2006_2';
- select * from dba_tab_partitions tp
- where tp.table_owner='SH' and tp.table_name='SALES_HISTORY_2006_2';
复制代码 | TABLE_OWNER | TABLE_NAME | COMPOSITE | PARTITION_NAME | SUBPARTITION_COUNT | HIGH_VALUE | HIGH_VALUE_LENGTH | PARTITION_POSITION | TABLESPACE_NAME | PCT_FREE | PCT_USED | INI_TRANS | MAX_TRANS | INITIAL_EXTENT | NEXT_EXTENT | MIN_EXTENT | MAX_EXTENT | MAX_SIZE | PCT_INCREASE | FREELISTS | FREELIST_GROUPS | LOGGING | COMPRESSION | COMPRESS_FOR | NUM_ROWS | BLOCKS | EMPTY_BLOCKS | AVG_SPACE | CHAIN_CNT | AVG_ROW_LEN | SAMPLE_SIZE | LAST_ANALYZED | BUFFER_POOL | GLOBAL_STATS | USER_STATS | 1 | SH | SALES_HISTORY_2006_2 | NO | SAL1 | 0 | <Long> | 83 | 1 | SALES_TBS1 | 10 | | 1 | 255 | 65536 | 1048576 | 1 | 2147483645 | 2147483645 | | | | YES | DISABLED | | | | | | | | | | DEFAULT | NO | NO | 2 | SH | SALES_HISTORY_2006_2 | NO | SAL2 | 0 | <Long> | 83 | 2 | SALES_TBS2 | 10 | | 1 | 255 | 65536 | 1048576 | 1 | 2147483645 | 2147483645 | | | | YES | DISABLED | | | | | | | | | | DEFAULT | NO | NO | 3 | SH | SALES_HISTORY_2006_2 | NO | SAL3 | 0 | <Long> | 83 | 3 | SALES_TBS3 | 10 | | 1 | 255 | 65536 | 1048576 | 1 | 2147483645 | 2147483645 | | | | YES | DISABLED | | | | | | | | | | DEFAULT | NO | NO | 4 | SH | SALES_HISTORY_2006_2 | NO | SAL4 | 0 | <Long> | 83 | 4 | SALES_TBS4 | 10 | | 1 | 255 | 65536 | 1048576 | 1 | 2147483645 | 2147483645 | | | | YES | DISABLED | | | | | | | | | | DEFAULT | NO | NO | 5 | SH | SALES_HISTORY_2006_2 | NO | SYS_P41 | 0 | <Long> | 83 | 5 | USERS | 10 | | 1 | 255 | 65536 | 1048576 | 1 | 2147483645 | 2147483645 | | | | YES | DISABLED | | | | | | | | | | DEFAULT | NO | NO | 6 | SH | SALES_HISTORY_2006_2 | NO | SYS_P42 | 0 | <Long> | 83 | 6 | USERS | 10 | | 1 | 255 | 65536 | 1048576 | 1 | 2147483645 | 2147483645 | | | | YES | DISABLED | | | | | | | | | | DEFAULT | NO | NO |
- create table sh.sales_history_2006(
- PROD_ID NUMBER NOT NULL,
- CUST_ID NUMBER NOT NULL,
- TIME_ID DATE NOT NULL,
- CHANNEL_ID NUMBER NOT NULL,
- PROMO_ID NUMBER NOT NULL,
- QUANTITY_SOLD NUMBER(10,2) NOT NULL,
- AMOUNT_SOLD NUMBER(10,2) NOT NULL
- )
- partition by range (time_id)
- interval(numtoyminterval(1,'YEAR'))
- (
- partition sal1 values less than (to_date('2003-01-01','YYYY-MM-DD')) tablespace SALES_TBS1,
- partition sal2 values less than (to_date('2004-01-01','YYYY-MM-DD')) tablespace SALES_TBS2,
- partition sal3 values less than (to_date('2005-01-01','YYYY-MM-DD')) tablespace SALES_TBS3,
- partition sal4 values less than (to_date('2006-01-01','YYYY-MM-DD')) tablespace SALES_TBS4
- )
复制代码- select to_char(hire_date,'YYYY-MM-DD:HH24:MI:SS') ,
- hire_date + interval '365 13:00:25.312' day(3) to second(3) from hr.employees
- where employee_id=100;
复制代码 | TO_CHAR(HIRE_DATE,'YYYY-MM-DD: | HIRE_DATE+INTERVAL'36513:00:25 | 1 | 1987-06-17:00:00:00 | 6/16/1988 1:00:25 PM |
- create table sh.sales_history_2006_3(
- PROD_ID NUMBER NOT NULL,
- CUST_ID NUMBER NOT NULL,
- TIME_ID DATE NOT NULL,
- CHANNEL_ID NUMBER NOT NULL,
- PROMO_ID NUMBER NOT NULL,
- QUANTITY_SOLD NUMBER(10,2) NOT NULL,
- AMOUNT_SOLD NUMBER(10,2) NOT NULL
- )
- partition by range (time_id)
- interval( interval '365 13:00:25.312' day(3) to second(3) )
- (
- partition sal1 values less than (to_date('2003-01-01','YYYY-MM-DD')) tablespace SALES_TBS1,
- partition sal2 values less than (to_date('2004-01-01','YYYY-MM-DD')) tablespace SALES_TBS2,
- partition sal3 values less than (to_date('2005-01-01','YYYY-MM-DD')) tablespace SALES_TBS3,
- partition sal4 values less than (to_date('2006-01-01','YYYY-MM-DD')) tablespace SALES_TBS4
- );
复制代码- select * from system_privilege_map m where m.name like 'FLASHBACK%';
复制代码 | PRIVILEGE | NAME | PROPERTY | 1 | -243 | FLASHBACK ANY TABLE | 0 | 2 | -350 | FLASHBACK ARCHIVE ADMINISTER | 0 |
---------------------
- Section 10: Capturing and Propagating Streams
- ---on emrep/prod1
- ---archive log list;
- ---check hr user on target
- alter system set global_names=true;
- create directory src_dir as '/home/oracle/files';
- create directory dst_dir as '/home/oracle/files';
- create tablespace streams_tbs datafile '/u01/app/oracle/oradata/PROD1/streams_tbs.dbf' size 100m
- /
- create user strmadmin identified by streams_123 default tablespace streams_tbs
- /
- grant dba,select_catalog_role,select any dictionary to strmadmin
- /
- begin
- dbms_streams_auth.grant_admin_privilege('STRMADMIN',true);
- end;
- /
- conn strmadmin/streams_123@prod1
- create database link emrep
- connect to strmadmin identified by streams_123
- using 'emrep'
- /
- conn strmadmin/streams_123@emrep
- create database link prod1
- connect to strmadmin identified by streams_123
- using 'prod1'
- /
- conn strmadmin/streams_123@prod1
- begin
- dbms_streams_adm.maintain_tables(
- table_names=>'hr.employees,hr.departments',
- source_directory_object=>'SRC_DIR',
- destination_directory_object=>'DST_DIR',
- source_database=>'PROD1',
- destination_database=>'EMREP',
- capture_name => 'PROD1_CAPTURE',
- propagation_name => 'PROD1_PROPAGATION',
- perform_actions=>true,
- bi_directional=>false,
- include_ddl=>true,
- instantiation=>dbms_streams_adm.instantiation_table_network
- );
- end;
- /
- select STREAMS_TYPE,rule_name,RULE_TYPE from DBA_STREAMS_TABLE_RULES
- conn hr/hr
- @3_10_4.sql
- BEGIN
- DBMS_STREAMS_ADM.SET_RULE_TRANSFORM_FUNCTION(
- rule_name => 'departments4',
- transform_function => 'hr.zero_sal');
- END;
- /
- ---if error see
- EXECUTE DBMS_STREAMS_ADM.REMOVE_STREAMS_CONFIGURATION();
- execute dbms_streams_adm.RECOVER_OPERATION(operation_mode = 'FORWARD'/operation_mode = 'ROLLBACK'/operation_mode = 'PURGE');
- DBA_RECOVERABLE_SCRIPT_ERRORS
- DBA_RECOVERABLE_SCRIPT
- DBA_RECOVERABLE_SCRIPT_PARAMS
- DBA_RECOVERABLE_SCRIPT_BLOCKS
复制代码
--------------------
- BEGIN
- dbms_resource_manager.clear_pending_area();
- dbms_resource_manager.create_pending_area();
- dbms_resource_manager.update_plan_directive(
- plan => 'DAYTIME',
- group_or_subplan => 'OLTP',
- new_switch_for_call => true
- );
- dbms_resource_manager.submit_pending_area();
- END;
复制代码
|
|