Mikael wrote:
tks. but as I said, I am quite new to DB2 and it seems not so easy for
me. Any sample codes out there or somebdy can show me?
Mikael
Jeroen van den Broek wrote:
>"Mikael" <mi************ @gmail.comschre ef in bericht
news:11******* *************** @75g2000cwc.goo glegroups.com.. .
ok. So, can not REORG TABLESPACE then.
How can I then REORG all my TABLES and INDEX easily without much
hassle. I do not want to be faced with the daunting task to go through
one by one.
This would be needed from time to time obviously.
Any utility (or whatever) out there that does the job? Perhaps
Highlight all the TABLES and INDEX and off you go?
Mikael Arhelger
Why not write a script that queries the DB2 Catalog Tables to generate
REORG TABLE / REORG INDEX statements for all your tables/indexes?
--
Jeroen
SELECT TABNAME FROM SYSCAT.TABLES WHERE TABSCHEMA = 'YOUR_SCHEMA'
SELECT INDNAME FROM SYSCAT.INDEXES WHERE INDSCHEMA = 'YOUR_SCHEMA'
Now you get table and index names in schema YOUR_SCHEMA.
Then you can write a sript that does the reorg:
SELECT 'REORG TABLE '|| RTRIM(LTRIM(TAB SCHEMA)) || '.' ||
RTRIM(LTRIM(TAB NAME)) FROM SYSCAT.TABLES WHERE TABSCHEMA = 'EMGSYS'
SELECT 'REORG INDEXES ALL FOR TABLE '|| RTRIM(LTRIM(TAB SCHEMA)) || '.' ||
RTRIM(LTRIM(TAB NAME)) FROM SYSCAT.TABLES WHERE TABSCHEMA = 'EMGSYS'
Now just copy the result (each column into one file) and run it:
DB2 CONNECT TO DB_NAME USER USER USING PASSWORD
DB2 -F your_table_file .sql
DB2 -F your_indexes_fi le.sql
Best regards,
Kovi
--
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
| Gregor Kovac |
Gr**********@mi kropis.si |
~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~ ~~~~
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-