Unix Technical Forum

Change a table's tablespace

This is a discussion on Change a table's tablespace within the DB2 forums, part of the Database Server Software category; --> Hi, i need to change the tablespace of a table, ie. use another tablespace for the table and stop ...


Go Back   Unix Technical Forum > Database Server Software > DB2

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-27-2008, 05:15 AM
sandip
 
Posts: n/a
Default Change a table's tablespace

Hi,

i need to change the tablespace of a table, ie. use another tablespace
for the table and stop the use of the existing tablespace. Is there any
way i can accomplish this? One solution might be export the data from
the table, re-create the tables in the new tablespace, drop the
original tablespace and load the data. But i would prefer another
simple and less time-consuming way.

Any suggestions would be highly appreciated.

Thanks in advance,
Sandip.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2 (permalink)  
Old 02-27-2008, 05:15 AM
Knut Stolze
 
Posts: n/a
Default Re: Change a table's tablespace

sandip wrote:

> Hi,
>
> i need to change the tablespace of a table, ie. use another tablespace
> for the table and stop the use of the existing tablespace. Is there any
> way i can accomplish this? One solution might be export the data from
> the table, re-create the tables in the new tablespace, drop the
> original tablespace and load the data. But i would prefer another
> simple and less time-consuming way.


You could create a new table in the other tablespace

CREATE TABLE <new-table> LIKE <old-table> IN <new-ts>

copy the data

INSERT INTO <new-nable> SELECT * FROM <old-table>

correct foreign keys to point to the new table and then remove the old
table.

--
Knut Stolze
Information Integration Development
IBM Germany / University of Jena
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 02-27-2008, 05:15 AM
Serge Rielau
 
Posts: n/a
Default Re: Change a table's tablespace

sandip wrote:
> Hi,
>
> i need to change the tablespace of a table, ie. use another tablespace
> for the table and stop the use of the existing tablespace. Is there any
> way i can accomplish this? One solution might be export the data from
> the table, re-create the tables in the new tablespace, drop the
> original tablespace and load the data. But i would prefer another
> simple and less time-consuming way.
>
> Any suggestions would be highly appreciated.
>
> Thanks in advance,
> Sandip.
>

You can do a "load from cursor". One way or another the data needs to move.

Cheers
Serge

--
Serge Rielau
DB2 SQL Compiler Development
IBM Toronto Lab
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 02-27-2008, 05:15 AM
hikums@gmail.com
 
Posts: n/a
Default Re: Change a table's tablespace

If the tablespace exists in the same instance, you can do it from
control center. Right click, copy table, enter new table/tablespace
name. then delete old and rename new table name to old table name.

Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 05:55 AM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0
www.UnixAdminTalk.com