File indexing completed on 2024-04-06 12:23:00
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023 SET NEWPAGE 0
0024 SET SPACE 0
0025 SET LINESIZE 80
0026 SET PAGESIZE 0
0027 SET ECHO OFF
0028 SET FEEDBACK OFF
0029 SET HEADING OFF
0030 SET MARKUP HTML OFF
0031
0032
0033 SPOOL SPLIT.sql
0034
0035 CREATE TABLE DUMMY (
0036 MYQUERY VARCHAR(1000)
0037 )
0038 /
0039
0040 BEGIN
0041 DECLARE
0042 step NUMBER :=100;
0043 imax NUMBER :=1000;
0044 i NUMBER :=step;
0045 q VARCHAR(1000) := '';
0046 BEGIN
0047 LOOP
0048 q := 'SELECT "ALTER TABLE ", REGEXP_REPLACE(TNAME, "$", ""),
0049 " SPLIT PARTITION ", REGEXP_REPLACE(TNAME, "$", "_0"),
0050 " AT (", i, ") INTO (PARTITION ", REGEXP_REPLACE(TNAME, "$", "_1"),
0051 ", PARTITION ", REGEXP_REPLACE(TNAME, "$", "_0"),
0052 ") UPDATE GLOBAL INDEXES;" FROM
0053 (SELECT T.TABLE_NAME TNAME, T.COLUMN_NAME COLNAME
0054 FROM USER_TAB_COLS T, USER_ALL_TABLES A
0055 WHERE T.TABLE_NAME = A.TABLE_NAME AND
0056 (T.COLUMN_NAME LIKE "%IOV%" AND T.DATA_TYPE LIKE "%NUMBER%")
0057 ) WHERE TNAME NOT LIKE "BIN%";';
0058 q := REGEXP_REPLACE(q, 'i', i);
0059 q := REGEXP_REPLACE(q, '"', '''');
0060 insert into dummy values (q);
0061 i := i+step;
0062 EXIT WHEN i > imax;
0063 END LOOP;
0064 END;
0065 END;
0066 /
0067
0068 SELECT * FROM DUMMY;
0069
0070 DROP TABLE DUMMY;
0071
0072 SPOOL OFF
0073
0074
0075 SPOOL MKPARTITIONS.sql
0076
0077
0078 SELECT 'CREATE TABLE ',REGEXP_REPLACE(TNAME, '$', '_2'),
0079 ' AS SELECT * FROM ', REGEXP_REPLACE(TNAME, '$', ''),
0080 ' PARTITION BY RANGE (', REGEXP_REPLACE(COLNAME, ' +$', ''),
0081 ') (PARTITION ', REGEXP_REPLACE(TNAME, '$', '_0'),
0082 ' VALUES LESS THAN (MAXVALUE));'
0083 FROM
0084 (SELECT T.TABLE_NAME TNAME, T.COLUMN_NAME COLNAME
0085 FROM USER_TAB_COLS T, USER_ALL_TABLES A
0086 WHERE T.TABLE_NAME = A.TABLE_NAME AND
0087 (T.COLUMN_NAME LIKE '%IOV%' AND T.DATA_TYPE LIKE '%NUMBER%')
0088 ) WHERE TNAME NOT LIKE 'BIN%';
0089
0090
0091
0092 SELECT 'DROP TABLE ', REGEXP_REPLACE(TNAME, '$', '') NEWTNAME,
0093 '; RENAME', REGEXP_REPLACE(TNAME, '$', '_2'), ' TO ',
0094 REGEXP_REPLACE(TNAME, '$', '') FROM
0095 (SELECT T.TABLE_NAME TNAME, T.COLUMN_NAME COLNAME
0096 FROM USER_TAB_COLS T, USER_ALL_TABLES A
0097 WHERE T.TABLE_NAME = A.TABLE_NAME AND
0098 (T.COLUMN_NAME LIKE '%IOV%' AND T.DATA_TYPE LIKE '%NUMBER%')
0099 ) WHERE TNAME NOT LIKE 'BIN%';
0100
0101
0102
0103 @SPLIT
0104
0105 SPOOL OFF
0106
0107