473,383 Members | 1,735 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Moving tables between tablespaces

Hello,

How does a use efficiently move a table between tablespaces, given that
the user doesn't have shell access to the server hosting the database?

Is there some built-in routine that the user can execute? - Such as a
function with the following parameters:

admin_move_table(
schemaname,
tablename,
destination_tablespace
)
Aug 18 '08 #1
9 12734
Hi!

Maybe this article an help you.
http://www.ibm.com/developerworks/db...dm-0602rielau/

Best regards,
Kovi

Troels Arvin pravi:
Hello,

How does a use efficiently move a table between tablespaces, given that
the user doesn't have shell access to the server hosting the database?

Is there some built-in routine that the user can execute? - Such as a
function with the following parameters:

admin_move_table(
schemaname,
tablename,
destination_tablespace
)
--
____________________________
|http://kovica.blogspot.com|
-----------------------------~-~-~-~-~-~-~-~-~-~-
| In A World Without Fences Who Needs Gates? |
| Experience Linux. |
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
Aug 18 '08 #2
Troels Arvin wrote:
Hello,

How does a use efficiently move a table between tablespaces, given that
the user doesn't have shell access to the server hosting the database?

Is there some built-in routine that the user can execute? - Such as a
function with the following parameters:

admin_move_table(
schemaname,
tablename,
destination_tablespace
)
There is no such thing in DB2 for LUW.
The easiest way is to do a CREATE TABLE LIKE followed by a LOAD from
CURSOR, a DROP and finally a RENAME TABLE.

Cheers
Serge

--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 18 '08 #3
Serge Rielau wrote:
>admin_move_table(
schemaname,
tablename,
destination_tablespace
)
There is no such thing in DB2 for LUW.
:-(

The easiest way is to do a CREATE TABLE LIKE followed by a LOAD from
CURSOR, a DROP and finally a RENAME TABLE.
Yes, that's also what I told the user to do. However, this will mean
losing indexes, constraints, permissions, and triggers as far as I can see.

--
Troels
Aug 18 '08 #4
Troels Arvin wrote:
Yes, that's also what I told the user to do. However, this will mean
losing indexes, constraints, permissions, and triggers as far as I can see.
You can check out the article Kovi pointed to.
It deals with these guys.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 18 '08 #5
"Serge Rielau" <sr*****@ca.ibm.comwrote in message
news:6g************@mid.individual.net...
Troels Arvin wrote:
>Yes, that's also what I told the user to do. However, this will mean
losing indexes, constraints, permissions, and triggers as far as I can
see.
You can check out the article Kovi pointed to.
It deals with these guys.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
I am a bit confused by the following statement in the article referenced:

"The composition of the DDL objects is entirely based on the documented
SYSCAT catalog views, with one exception. The high watermark for an IDENTITY
column needs to be retrieved from SYSIBM.SYSSEQUENCES.LASTASSIGNVAL, which
is not exposed in DB2 UDB V8."

Does COPYSCHEMA(<TARGETSCHEMA>,<TARGETTABLESPACEINFO>,< SOURCESCHEMA>) reset
the sequences and/or indentify columns to the same last assinged value as
the source schema? Does the COPYSCHEMA SP work differently in V9.5 versus
V8 in this regard?
Aug 18 '08 #6
Mark A wrote:
"Serge Rielau" <sr*****@ca.ibm.comwrote in message
news:6g************@mid.individual.net...
>Troels Arvin wrote:
>>Yes, that's also what I told the user to do. However, this will mean
losing indexes, constraints, permissions, and triggers as far as I can
see.
You can check out the article Kovi pointed to.
It deals with these guys.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

I am a bit confused by the following statement in the article referenced:

"The composition of the DDL objects is entirely based on the documented
SYSCAT catalog views, with one exception. The high watermark for an IDENTITY
column needs to be retrieved from SYSIBM.SYSSEQUENCES.LASTASSIGNVAL, which
is not exposed in DB2 UDB V8."

Does COPYSCHEMA(<TARGETSCHEMA>,<TARGETTABLESPACEINFO>,< SOURCESCHEMA>) reset
the sequences and/or indentify columns to the same last assinged value as
the source schema? Does the COPYSCHEMA SP work differently in V9.5 versus
V8 in this regard?
Yes.... in the same sense as the value is preserved by a
db2stop/db2start. The tool works the same on DB2 V8 and DB2 9.5. It's
just that the column in question wasn't exposed in DB2 V8.

Cheers
Serge
--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Aug 18 '08 #7
"Serge Rielau" <sr*****@ca.ibm.comwrote in message
news:6g************@mid.individual.net...
Yes.... in the same sense as the value is preserved by a db2stop/db2start.
The tool works the same on DB2 V8 and DB2 9.5. It's just that the column
in question wasn't exposed in DB2 V8.

Cheers
Serge

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
I tried using the stored procedure SYSPROC.ADMIN_COPY_SCHEMA to copy a
schema from one name to another in the same database.

1. The proc I executed above is a different stored procedure than mentioned
in the link from this thread. The one I used above comes with DB2 V9.5.

2. When I call the stored procedure, it copies the schema and data (if I use
COPY or COPYNO), but it does not set the identity column last value to the
same values as the source schema, so that upon the first insert into the new
schema there is a duplicate unique constraint error (-803).
Aug 18 '08 #8
>>On 8/18/2008 at 4:34 PM, in message
<wJ******************@bignews9.bellsouth.net>, Mark A<xx****@xxxxx.com>
wrote:
"Serge Rielau" <sr*****@ca.ibm.comwrote in message
news:6g************@mid.individual.net...
>Yes.... in the same sense as the value is preserved by a
db2stop/db2start.
>The tool works the same on DB2 V8 and DB2 9.5. It's just that the column
>
>in question wasn't exposed in DB2 V8.

Cheers
Serge

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

I tried using the stored procedure SYSPROC.ADMIN_COPY_SCHEMA to copy a
schema from one name to another in the same database.

1. The proc I executed above is a different stored procedure than
mentioned
in the link from this thread. The one I used above comes with DB2 V9.5.

2. When I call the stored procedure, it copies the schema and data (if I
use
COPY or COPYNO), but it does not set the identity column last value to
the
same values as the source schema, so that upon the first insert into the
new
schema there is a duplicate unique constraint error (-803).
As far as I can tell this is "working as designed". However, it could use
some "design improvement" in my opinion. Here is a thread I participated in
in the DB2 Express forum:

http://www.ibm.com/developerworks/fo...214937&tstart=
30

Especially look at my post dated Jul 25, 2008 07:36:26 PM and the response
from Raul Chong of IBM on Jul 28, 2008 10:04:17 AM.

What do you think?

Frank

Aug 19 '08 #9
"Frank Swarbrick" <Fr*************@efirstbank.comwrote in message
news:48******************@efirstbank.com...
As far as I can tell this is "working as designed". However, it could use
some "design improvement" in my opinion. Here is a thread I participated
in
in the DB2 Express forum:

http://www.ibm.com/developerworks/fo...214937&tstart=
30

Especially look at my post dated Jul 25, 2008 07:36:26 PM and the response
from Raul Chong of IBM on Jul 28, 2008 10:04:17 AM.

What do you think?

Frank

I agree that it is working as designed. When I first used that SP
(SYSPROC.ADMIN_COPY_SCHEMA) I just assumed it would start sequences and
identity columns at 1 (assuming they were initially defined that way) and I
wrote my own script to reset them to the correct values. But I am not sure
if my script below would work correctly on a database that is actively being
used (in my case it was not being used when the script ran, and I stopped
and started the instance before running it).

Note that after I copy the schema with the above stored proc, the original
schema is DB2INST1 and the new one is DB2INST2. After I reset the sequences,
I can then drop the objects in the old schema.

db2 connect to <dbanme>

db2 -x "select 'alter sequence DB2INST2.'||rtrim(SEQNAME)||' restart with ',
cast(NEXTCACHEFIRSTVALUE as int), ';' from syscat.sequences where seqschema
= 'DB2INST1'" alter_seq.txt

db2 -tvf alter_seq.txt alter_seq.out
Aug 19 '08 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Edwinah63 | last post by:
Dear Everyone, how can i move items such as indivual tables, stored procs, functions, sequences and other user defined bits and pieces between 1. schemata within a database instance? 2....
57
by: Bing Wu | last post by:
Hi all, I am running a database containing large datasets: frames: 20 thousand rows, coordinates: 170 million row. The database has been implemented with: IBM DB2 v8.1
11
by: Data Goob | last post by:
Hi, I thought we would be able to have indexes in a separate tablespace from the tables in another tablespace. So I went and created a INDEXSPACE1, only to not see the syntax on how to create...
5
by: Christian Traber | last post by:
Hi! just playing with tablespaces... - moved a existing table to a new tablespace - tried to move it back to default tablespace (ALTER TABLE accounts SET TABLESPACE pg_default;) Got the...
2
by: db2dude | last post by:
Hello all, I have a database around 600GB and all tables were self-created by the application. Hence, we have only one huge SMS tablespace where all the tables are stored. To get better...
2
by: fuzzybr80 | last post by:
I am using MySQL 5.0 with a number of innodb tables whose ibdata files are growing quite quickly and filling up the /var partition (file is /var/mysql/ibdata1). Earlier on I followed instructions...
3
by: dcruncher4 | last post by:
DB2 8.2.3 the task I have is to write a script to restore a database from a backup on to another machine. the backup can be as old as seven years. The container layout on the machine to be...
4
by: Troels Arvin | last post by:
Hello, I've run into situations where a table was accidentally dropped. The related database contained lots of other tables in lots of other schemas used by many different users. So I couldn't...
4
by: db2admin | last post by:
Hello, I want to plan rearranging tables in our database according to business areas. say all tables in business area A will be in seperate tablespace or tablespaces. I am planning to monitor...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.