473,414 Members | 1,575 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,414 software developers and data experts.

List tablespaces work, but not SQL

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 restored
can be totally different from the machine which was backedup. So we are
going with redirect
restore.

I plan to write a script in perl to change all containers from the
original path to the new
path and then complete the redirect restore.

The first task is to get the information about the tablespaces and
container
as it existed on the backup image. It seems the only way is to do the
following:
db2 restore db dbname from /dev/rmt/0c taken at yyyymmdd into tmpdb
redirect without prompting

db2 list tablespaces

db2 list tablespace containers for 5 show detail
....

what it does is to create a new tmp db in an inconsistent state and
leaves my current db2 session connected to that. the next two lines
(list tablespaces) shows me the information
about tablespaces and containers as it existed on the backup image.
that information
can be saved and after that it is easy to reconstruct all required
information for the redirect restore.

Then we decided to not use list tablespaces command, but use perl DBI
as it makes the
code easier to maintain. The SQL for that is

select tbspaceid,tbspace
from syscat.tablespaces ;
select
tablespace_id,container_id,total_pages,substr(cont ainer_name,1,40)
from table (snapshot_container('',-1)) as A
order by tablespace_id,container_id ;

Now here is the problem. Db2 does not allow any SELECT statment on the
tmpdb after it
got created by the db2 restore db command. It tells

SQL3022N An SQL error "-1350" occurred while processing the SELECT
string in
the Action String parameter.

SQL1350N The application is not in the correct state to process this
request.
Reason code="3".

Why is DB2 allowing list tablespaces to work, but not the equivalent
SQL command?
IMO this is annoying even though I can understand why this is
happening. I think list tablespaces
directly goes to the NODE directory and reads it from the catalog files
created there, bypassing
the engine.

Anyhow, solutions from anyone?

TIA.

Oct 26 '06 #1
3 4830
Lew
use the db2bkckp command with -t option. you'll have to parse the
output but it shouldn't too bad

Lew

dc********@aim.com wrote:
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 restored
can be totally different from the machine which was backedup. So we are
going with redirect
restore.

I plan to write a script in perl to change all containers from the
original path to the new
path and then complete the redirect restore.

The first task is to get the information about the tablespaces and
container
as it existed on the backup image. It seems the only way is to do the
following:
db2 restore db dbname from /dev/rmt/0c taken at yyyymmdd into tmpdb
redirect without prompting

db2 list tablespaces

db2 list tablespace containers for 5 show detail
...

what it does is to create a new tmp db in an inconsistent state and
leaves my current db2 session connected to that. the next two lines
(list tablespaces) shows me the information
about tablespaces and containers as it existed on the backup image.
that information
can be saved and after that it is easy to reconstruct all required
information for the redirect restore.

Then we decided to not use list tablespaces command, but use perl DBI
as it makes the
code easier to maintain. The SQL for that is

select tbspaceid,tbspace
from syscat.tablespaces ;
select
tablespace_id,container_id,total_pages,substr(cont ainer_name,1,40)
from table (snapshot_container('',-1)) as A
order by tablespace_id,container_id ;

Now here is the problem. Db2 does not allow any SELECT statment on the
tmpdb after it
got created by the db2 restore db command. It tells

SQL3022N An SQL error "-1350" occurred while processing the SELECT
string in
the Action String parameter.

SQL1350N The application is not in the correct state to process this
request.
Reason code="3".

Why is DB2 allowing list tablespaces to work, but not the equivalent
SQL command?
IMO this is annoying even though I can understand why this is
happening. I think list tablespaces
directly goes to the NODE directory and reads it from the catalog files
created there, bypassing
the engine.

Anyhow, solutions from anyone?

TIA.
Oct 26 '06 #2

Lew wrote:
use the db2bkckp command with -t option. you'll have to parse the
output but it shouldn't too bad
db2bkckp does not work with Legato backups. IBM tech support told
us that. we backup small dbs on tapes and big ones on legato.

Oct 26 '06 #3
Ian
dc********@aim.com wrote:
Lew wrote:
>use the db2bkckp command with -t option. you'll have to parse the
output but it shouldn't too bad

db2bkckp does not work with Legato backups. IBM tech support told
us that. we backup small dbs on tapes and big ones on legato.
Then I would suggest that you capture a snapshot of your tablespace
layout prior to doing the backup. (i.e. get snapshot for tablespaces
on DB).

The DB2 module for NetWorker has the ability to run pre-backup scripts
as well as specify additional files/directories that should get saved
with the database backup, so you could leverage these two things to
collect/store this info with your DB2 backups.

Oct 26 '06 #4

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

Similar topics

1
by: CK | last post by:
Need a piece of advice on allocation of tablespaces for partitioning We are using a day level range-based approach as our parititiong scheme given that we have data inflows running into 15...
3
by: Vissu | last post by:
Hi , We will have about 50 tables. Some tables will be huge (severel million rows) and some are small but most of them will have about a million rows. For best performance of the database, how...
1
by: Odd Bjørn Andersen | last post by:
Environment: AIX 4.3.3 DB2 UDB WSE version 8.1 fixpack 9a When I access a database residing on this server from my workstation (Windows xp, servicepack2 - db2 udb ESE fixpack 10) and in Control...
6
by: mike_dba | last post by:
Can anyone tell me why a EEE system might be created to have two separate tablespaces with the same 4k pagesize ? They both appear to be in use as I can see the underlying files being modified. ...
10
by: rAinDeEr | last post by:
Hi, I am trying to create around 70 tablespaces for around 100 tables.. Am using DB2 UDB 8.2 in Linux environment... This is one i generated through Control centre.... CREATE REGULAR...
4
by: beena | last post by:
All, I'm new to the concept of automatic storage... I'm looking at the database setup by a vendor. I see few tablespaces showing up with automatic storage - Yes. Tablespace ID ...
8
by: alexhguerra | last post by:
Hello If im not missing something, when looking into directories that are SMS containers i can see multiple files, one for table data, one for indexes and other for lobs. Is there any special...
1
by: Justin | last post by:
I am restoring a database (approximately 1 Terabyte). After the restore started, I noticed that the "list utilities" completed work was not being updated. I checked the location of the restore...
6
by: Troels Arvin | last post by:
Hello, I have recently run a rather large data import where the imported data i pumped through some updatable views equipped with INSTEAD OF triggers. For various reasons, the exact same data...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.