If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > Moving table from tablespace to another

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-12-10, 07:02
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
Moving table from tablespace to another

I am moving a table from one tablespace to another. As 9.7 has a new feature to do this online, I tried doing it with ADMIN_MOVE_TABLE procedure but its taking for ever to finish as the table has 20 GB of data and index pages. As I can get the outage from application to do this move offline, I decided to do it in old fashion. Recreating a table in the new tablespace and performing a cursor load from the old table.

Can someone please tell me what are the steps required to do this ? What all dependencies of the old table needs to be dropped and recreated for the new table ?. Here is what I am planning to do.

Take a db2look output of the old table
db2look -d dbname -e -x -z schemaname -t tablename
Drop the foreign keys from the old table
Rename the older table
modify the db2look output to reflect it to the new tablespace and commenting out the foreign key creation section
run the modified db2look output
Do a cursor load from the old renamed table to the new table created
Recreate the foreign keys.

Please let me know if I am missing something. Do I need to drop any more dependencies other than the foreign keys ?

Any help would be greatly appreciated.

Last edited by blazer789; 02-12-10 at 07:05.
Reply With Quote
  #2 (permalink)  
Old 02-12-10, 07:24
nvk@vhv nvk@vhv is offline
Registered User
 
Join Date: Jan 2010
Posts: 294
I would use -xd in the db2look. Maybe the created by another user. You would lose this permissions.

The views are included in the db2look. What about views on the views (depending views)?

Good to get some feedback on the ADMIN_MOVE_TABLE. Sounded like a nice feature, but it seems to be unusable. Reminds me on online table reorg.
Reply With Quote
  #3 (permalink)  
Old 02-12-10, 10:12
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
Sounds about right. Just before you do a RENAME, make sure you drop all of the dependent objects. Wait until you re done with the final load before creating them.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #4 (permalink)  
Old 02-12-10, 10:18
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
Reply to nvk@vhv:
Well, I don't say ADMIN_MOVE_TABLE is unusable. I was actually trying to do that on a test database whose host is an capped LPAR with 0.4 Entitled Capacity [CPU]. Small tables which were 1.3 GB in size took about 8 minutes. But because I had to drop the foregin keys, I had to do it in an outage window. As anyways it is an outage I thought its better to go with cursor load which is much faster.
Reply With Quote
  #5 (permalink)  
Old 02-12-10, 10:31
nvk@vhv nvk@vhv is offline
Registered User
 
Join Date: Jan 2010
Posts: 294


Planed to do some testings with it.
Reply With Quote
  #6 (permalink)  
Old 02-12-10, 10:34
blazer789 blazer789 is offline
Registered User
 
Join Date: Jun 2009
Posts: 221
REPLY TO COUGAR800

All the dependent object I have are
1. Indexes
2. Packages

Packages :- I guess I don't need to drop the packages. After renaming the table, the packages get invalidated and once I rebind that package I believe it becomes the dependent of the new table -- Correct me if I am wrong

Indexes :- Can someone please tell me which way is faster ? Create the new table, create the indexes and load the data OR Just create the new table without indexes, load the data and then recreate the indexes
Reply With Quote
  #7 (permalink)  
Old 02-12-10, 11:12
Cougar8000 Cougar8000 is offline
Registered User
 
Join Date: Nov 2005
Location: IL
Posts: 554
packages - you are correct.

Indexes - I would build indexes first. Advantage is not worth it. At least in cases where I was involved in.
__________________
--
IBM Certified DBA on DB2 for Linux, UNIX, and Windows

DB2 v9.1.0.2 os 5.3.0.0
Reply With Quote
  #8 (permalink)  
Old 02-13-10, 14:40
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
About packages, yes, technically you are right ... But, I would recommend doing it manually as your apps need not wait for the rebind to happen and in worst case scenario, if the rebind fails, it will not be when the apps are online.

As cogur8000 says, it is best to create indexes beforehand. db2 does data loads and sorting for indexes simaltaneously in the LOAD phase. also, multiple indexes are built at the same time in the BUILD phase. the exception will be when your IO system cannot handle such parallel operations.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On