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 call several create table statements???

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-09-04, 06:34
Juan Gonzales Juan Gonzales is offline
Registered User
 
Join Date: Feb 2004
Posts: 2
Question how to call several create table statements???

hi guys,

i am new to db2.
How can i call several create table statements in just one script.
it would be also great to set the schema in that script.
is there a special tool from db2 availabel or is java an option?
please help me out here (with examples)!!!!!

Thanx
juan
Reply With Quote
  #2 (permalink)  
Old 06-09-04, 07:08
Marcus_A Marcus_A is online now
Registered User
 
Join Date: May 2003
Location: USA
Posts: 5,196
Create a file with the SQL statements you want. These can include set schema, create table, or msot other SQL statement. Separate each SQL statement with semi-colon ( ; ).

Then from your OS command prompt execute the following (assume the above file with your SQL statements is named "sql_input"):

db2 –tvf sql_input

See the Command Reference manual for other Command Line Processor options. To download DB2 manuals, see the first thread entitled Useful DB2 Stuff.
__________________
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 06-10-04, 04:14
shedb shedb is offline
Registered User
 
Join Date: Dec 2003
Posts: 78
Smile example

use notepad, save with extension sql,this should work:

example.sql:

SET CURRENT SCHEMA MYSCHEMA
CREATE TABLE "MYSCHEMA"."MYTABLE1" (
"MYVARCHAR1" VARCHAR(255) NOT NULL,
"MYINTEGER1" INTEGER NOT NULL,
"MYCHAR1" CHAR(20) NOT NULL
);
CREATE TABLE "MYSCHEMA"."MYTABLE2" (
"MYVARCHAR2" VARCHAR(255) NOT NULL,
"MYINTEGER2" INTEGER NOT NULL,
"MYCHAR2" CHAR(20) NOT NULL
);


i suggest u put some blank lines at the end of the file.

then using Command line processor, do the following:


db2 => quit
DB20000I The QUIT command completed successfully.

C:\PROGRA~1\SQLLIB\BIN>
C:\PROGRA~1\SQLLIB\BIN>db2 connect to mydb
....

C:\PROGRA~1\SQLLIB\BIN>db2 -tvf example.sql


note that after quit, you should change your directory to where you have saved the file with "cd" command
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