472,354 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

Is there an easy to copy a table: structure and data?

For testing purposes I propose to add a schema (testing, how original)
and would like to copy some of my live tables to it, both structure and
data. I know I could use something like dump/restore for the data and
Quest's (BTW this a very nice product) 'create like' function. That
would work, but it seems a lot of work for something DB2 should know how
to do.

Nov 12 '05 #1
4 38630
db2look with -e -t can give you the table CREATE statements.

The DB2 Control Center will allow you to copy a table and its contents.

You can also do a CREATE ... LIKE to copy the table structure (but not
the rows):

create table emp2 like employee

you could then do an insert:

insert into emp2 (select * from employee)

Robert Stearns wrote:
For testing purposes I propose to add a schema (testing, how original)
and would like to copy some of my live tables to it, both structure and
data. I know I could use something like dump/restore for the data and
Quest's (BTW this a very nice product) 'create like' function. That
would work, but it seems a lot of work for something DB2 should know how
to do.


Nov 12 '05 #2
db2look with -e -t can give you the table CREATE statements.

The DB2 Control Center will allow you to copy a table and its contents.

You can also do a CREATE ... LIKE to copy the table structure (but not
the rows):

create table emp2 like employee

you could then do an insert:

insert into emp2 (select * from employee)

Robert Stearns wrote:
For testing purposes I propose to add a schema (testing, how original)
and would like to copy some of my live tables to it, both structure and
data. I know I could use something like dump/restore for the data and
Quest's (BTW this a very nice product) 'create like' function. That
would work, but it seems a lot of work for something DB2 should know how
to do.


Nov 12 '05 #3
Blair Adamache wrote:
db2look with -e -t can give you the table CREATE statements.

The DB2 Control Center will allow you to copy a table and its contents.

You can also do a CREATE ... LIKE to copy the table structure (but not
the rows):

create table emp2 like employee

you could then do an insert:

insert into emp2 (select * from employee)

Robert Stearns wrote:
For testing purposes I propose to add a schema (testing, how original)
and would like to copy some of my live tables to it, both structure and
data. I know I could use something like dump/restore for the data and
Quest's (BTW this a very nice product) 'create like' function. That
would work, but it seems a lot of work for something DB2 should know how
to do.


Another alternative would be to take an EXPORT to IXF format, and then do an
IMPORT with the "REPLACE_CREATE" option. This would work across databases
as well. It will only give you the basic table structure and data, and
you'd need to use db2look to generate the statements to add indexes etc.

HTH

Phil
Nov 12 '05 #4
Blair Adamache wrote:
db2look with -e -t can give you the table CREATE statements.

The DB2 Control Center will allow you to copy a table and its contents.

You can also do a CREATE ... LIKE to copy the table structure (but not
the rows):

create table emp2 like employee

you could then do an insert:

insert into emp2 (select * from employee)

Robert Stearns wrote:
For testing purposes I propose to add a schema (testing, how original)
and would like to copy some of my live tables to it, both structure and
data. I know I could use something like dump/restore for the data and
Quest's (BTW this a very nice product) 'create like' function. That
would work, but it seems a lot of work for something DB2 should know how
to do.


Another alternative would be to take an EXPORT to IXF format, and then do an
IMPORT with the "REPLACE_CREATE" option. This would work across databases
as well. It will only give you the basic table structure and data, and
you'd need to use db2look to generate the statements to add indexes etc.

HTH

Phil
Nov 12 '05 #5

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

Similar topics

0
by: QWERTY | last post by:
--------------Boundary-00=_O5I3QL80000000000000 Content-Type: Multipart/Alternative; boundary="------------Boundary-00=_O5I3LVC0000000000000" --------------Boundary-00=_O5I3LVC0000000000000...
0
by: Randall Sell | last post by:
Hello all, I am migrating a Paradox application to SQL Server. My problem is that the existing Paradox table structure is limited. Correcting it will mean a re-write of the application (Delphi...
2
by: spamproof2005 | last post by:
Is there a way to copy the structure from one database to another without affecting the actual data? For example, I added new fields and stored procedures to a db in my development environment....
5
by: Stewart Allen | last post by:
Hi all, I'm designing a club database and have encountered a problem when trying to extract the total amount of fees that a Student/Family is suppose to pay during their time of membership. I've...
3
by: Leo Nunez | last post by:
Hello! I need copy from structure "A" to "B" that contains "strings" in a one line code. Me problem like this : typedef struct tHeader{ char field1; char field2; char field3;
1
by: Mo | last post by:
Hi, I have two datasets on two databases one remote and one local. I am trying to copy the local data into the remote. Both tables have the same structure. I use the following DataTable...
2
by: charles-brewster | last post by:
I'm trying to write a simple JavaScript function which will use a button to copy table cell data into a form input text box as the "value" attribute. The following is intended to test the...
3
by: jc | last post by:
Hello. I want to ask about the possibility of copying both a table structure and it's contents from a SQL server table to a table within MS access. The problem cannot be solve with a permanent...
9
by: sck10 | last post by:
Hello, I am building a web form that will be used to gather information for marketing plans. The form will have 15 questions which must be answered. Each question can have large blocks of text....
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was proposed, which integrated multiple engines and...
1
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. header("Location:".$urlback); Is this the right layout the...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it so the python app could use a http request to get...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...

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.