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 > How to run a ddl script?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 01-28-09, 08:50
mahendrakariya mahendrakariya is offline
Registered User
 
Join Date: Jan 2009
Posts: 6
Question How to run a ddl script?

Let me first mention that i am a newbie.

I had developed a database. Before formatting my system, I had generated the ddl script and a backup of the database.

Now i want the same tables and the data that I had earlier.

I tried to run the command db2 -tvf TGMC2008 - DDL
But i am getting SQL5005C System Error.

Kindly guide me. also tell me how to use the backup data.
Reply With Quote
  #2 (permalink)  
Old 01-28-09, 09:37
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Assume you script is named TGMC2008.DDL and contains the following

Code:
connect to sample;

select * from emp;

alter table emp add column imigration_status smallint;

connect reset;
The run the script with this:

db2 -tvf TGMC2008.DDL > TGMC2008.OUT

Note that in Linux and UNIX, the file names are case sensitive.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #3 (permalink)  
Old 01-28-09, 10:06
MarkhamDBA MarkhamDBA is offline
Registered User
 
Join Date: Dec 2008
Location: Toronto, Canada
Posts: 381
[QUOTE=mahendrakariya]I had developed a database. Before formatting my system, I had generated the ddl script and a backup of the database. Now i want the same tables and the data that I had earlier.
QUOTE]

It might not answer your question but why don't you just restore your db? Then you don't need to create all objects one by one and load tables.
__________________
DB2 v9.5 ESE on AIX v6.1/ v9./10 on z/OS
Reply With Quote
  #4 (permalink)  
Old 01-28-09, 10:10
nick.ncs nick.ncs is offline
Registered User
 
Join Date: May 2007
Location: somewhere in dbforums
Posts: 221
DDL scripts will only create your db structure but will have no data....so the best thing is to restore the db
__________________
IBM Certified Database Associate, DB2 9 for LUW
Reply With Quote
  #5 (permalink)  
Old 01-29-09, 08:20
mahendrakariya mahendrakariya is offline
Registered User
 
Join Date: Jan 2009
Posts: 6
Quote:
Originally Posted by nick.ncs
DDL scripts will only create your db structure but will have no data....so the best thing is to restore the db
Thanks... Can u tell me how can i restore the db. I have the ddl script as well as the backup of the db.
Reply With Quote
  #6 (permalink)  
Old 01-29-09, 10:40
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by mahendrakariya
Thanks... Can u tell me how can i restore the db. I have the ddl script as well as the backup of the db.
You use the RESTORE DATABASE command for that.
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #7 (permalink)  
Old 01-30-09, 08:35
mahendrakariya mahendrakariya is offline
Registered User
 
Join Date: Jan 2009
Posts: 6
Thanks for all this help. But i m still not getting it. The ddl file is named TGMC2008 - DDL.ddl and the backup file is named TGMC2008.0.DB2 -- Backup. The original db name was TGMC2008. I just want to restore it. What command should I use?
Reply With Quote
  #8 (permalink)  
Old 01-30-09, 09:18
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
If you have a bakcup file, then using RESTORE command will get both the table structures, indexes etc and the data. It is not necessary to run the DDL.

In your original post, you have mentioned about SQL5005C ... That has nothing to do with your ddl or restore ..
Code:
SQL5005C System Error.
Explanation:
A system error, probably an I/O error, was encountered while
accessing a configuration file.
 The command cannot be processed.
User Response:
Resubmit the command.
 If the error persists, check the db2diag.log file for details
and ensure that the configuration file is accessible. If unable
to resolve the problem, contact an IBM Service Representative for
assistance.
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #9 (permalink)  
Old 01-30-09, 11:41
stolze stolze is offline
Registered User
 
Join Date: Jan 2007
Location: Jena, Germany
Posts: 2,662
Quote:
Originally Posted by mahendrakariya
Thanks for all this help. But i m still not getting it. The ddl file is named TGMC2008 - DDL.ddl and the backup file is named TGMC2008.0.DB2 -- Backup. The original db name was TGMC2008. I just want to restore it. What command should I use?
Sorry, I don't understand your question at all. If you search in the DB2 manuals, you will find the "RESTORE" command that all of us are referring to. Is there some problem with using this command?
__________________
Knut Stolze
IBM DB2 Analytics Accelerator
IBM Germany Research & Development
Reply With Quote
  #10 (permalink)  
Old 01-30-09, 11:59
Marcus_A Marcus_A is offline
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Quote:
Originally Posted by mahendrakariya
Thanks for all this help. But i m still not getting it. The ddl file is named TGMC2008 - DDL.ddl and the backup file is named TGMC2008.0.DB2 -- Backup. The original db name was TGMC2008. I just want to restore it. What command should I use?
The command is:

find experienced DBA

We are not hear to help people who know absolutely nothing about DB2.
__________________
M. A. Feldman
IBM Certified DBA on DB2 for Linux, UNIX, and Windows
IBM Certified DBA on DB2 for z/OS and OS/390
Reply With Quote
  #11 (permalink)  
Old 01-31-09, 07:24
przytula_guy przytula_guy is offline
Registered User
 
Join Date: Apr 2006
Location: Belgium
Posts: 1,159
please be more specific with all questions you ask
we can not see what you are doing or wanting todo
give as much as possible details with a complete scenario and why you want todo this. in that case we might be able to help
at least, have a look at infocenter/books for all possible commands/syntax as they have been created for that purpose
__________________
Best Regards, Guy Przytula
Database Software Consultant
DB2 UDB LUW Certified V7-V8-V9-V9.7 DB Admin - Dprop..
Information Server Datastage Certified
http://www.infocura.be
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