Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
Database Servers
DB2InformixIngresMS SQLOraclePervasive.SQLPostgreSQLProgressSybase
Desktop Databases
FileMakerFoxProMS AccessParadox
General
General DB TopicsDatabase Theory
Related Topics
Java Development.NET DevelopmentVB DevelopmentMore Topics ...

Database Forum / DB2 Topics / February 2006

Tip: Looking for answers? Try searching our database.

import sql dump

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Franz Demmel - 17 Feb 2006 16:19 GMT
Hi,

I'm quite new to DB2. I've created a db scheme with DBDesigner4 and then
I created an export file with all the sql statements. Now I'm wondering
if at all and if yes how it is possible to create tables from a sql
dump. Or should I use other tools?

regards,

Franz
Serge Rielau - 17 Feb 2006 16:45 GMT
> Hi,
>
> I'm quite new to DB2. I've created a db scheme with DBDesigner4 and then
>  I created an export file with all the sql statements. Now I'm wondering
> if at all and if yes how it is possible to create tables from a sql
> dump. Or should I use other tools?
This is a bit vague. Care to post some representative peice of this "SQL
dump"?
If you also have the CREATE TABLE statements then all you may need to do
is execute db2 -t<yourdelimiter> -f <filename>

Signature

Serge Rielau
DB2 Solutions Development
IBM Toronto Lab

Franz Demmel - 17 Feb 2006 17:10 GMT
> This is a bit vague. Care to post some representative peice of this "SQL
> dump"?
> If you also have the CREATE TABLE statements then all you may need to do
> is execute db2 -t<yourdelimiter> -f <filename>
The whole sql file is just for creating table. Here is a part of the sql
file:
...
CREATE TABLE category (
 id INTEGER NOT NULL AUTO_INCREMENT,
 category CHAR(255)) NULL,
 PRIMARY KEY(id)
);

CREATE TABLE user_context_history (
 id INTEGER NOT NULL AUTO_INCREMENT,
 users_fkid INTEGER NOT NULL,
 longitude DOUBLE NULL,
 latitude DOUBLE NULL,
 category INTEGER NULL,
 PRIMARY KEY(id, users_fkid),
 FOREIGN KEY(users_fkid)
   REFERENCES users(id)
     ON DELETE NO ACTION
     ON UPDATE NO ACTION
);
...

When I tried: db2 -t ; -f d:\db.sql I get the following error:
DB21034E The command was processed as an sql command....
SQL processing: SQL1024N No connection to database.
But in the command centre I right-clicked on the database and selected
connect.
By the way. I can't figure out at which port db2 is listening.
m0002a@yahoo.com - 17 Feb 2006 17:28 GMT
You need to run:
db2 connect to database-name; (or include it in your script)

You find the port with db2 get dbm cfg
If it lists a service name, then you need to look in /etc/services for
the translation. The default is 50000.
Franz Demmel - 17 Feb 2006 19:17 GMT
m0002a@yahoo.com schrieb:
> You need to run:
> db2 connect to database-name; (or include it in your script)
>
> You find the port with db2 get dbm cfg
> If it lists a service name, then you need to look in /etc/services for
> the translation. The default is 50000.

Thanks. I will try. As you see my questions are very simple. Is there a
good resource for DB2 to lookup such essential infos? The manual
provided by IBM very, very detailed and it's hard to find such
information very quickly.
m0002a@yahoo.com - 17 Feb 2006 16:52 GMT
> Hi,
>
[quoted text clipped - 6 lines]
>
> Franz

run the script as follows from a telnet session or command window:

db2 -tvf script-name.ddl > results.out
cheng.j3@gmail.com - 18 Feb 2006 04:37 GMT
After  you connect  to a  exist  db,  you may  try "db2 -tvf  <your
file name>" . If  there is no delimiter ';" at the end of each DDL
statement, just use "db2 -vf  <your file name>" .

Cheng
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.