473,508 Members | 2,327 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 38829
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
1824
by: QWERTY | last post by:
--------------Boundary-00=_O5I3QL80000000000000 Content-Type: Multipart/Alternative; boundary="------------Boundary-00=_O5I3LVC0000000000000" --------------Boundary-00=_O5I3LVC0000000000000...
0
2427
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
10404
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
2061
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
2973
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
4038
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
13830
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
2482
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
1719
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
7224
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
7120
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
7323
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7380
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5626
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,...
1
5050
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3192
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3180
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
763
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.