I was wondering if there was a way to create a copy of a table in a
single SQL statement, together with its column structure and data. In
Oracle, there is a "CREATE TABLE new-table AS select-statement" that I
can use to accomplish this.
Is there a similar statement in DB2? I found a similar syntax
structure under materialized query tables, but it appeared that the
new table would remain tied to the original source in some way.
Perhaps I am mistaken? 5 12794
"DB_2" <de*******@yahoo.com> wrote in message
news:9b**************************@posting.google.c om... I was wondering if there was a way to create a copy of a table in a single SQL statement, together with its column structure and data. In Oracle, there is a "CREATE TABLE new-table AS select-statement" that I can use to accomplish this.
Is there a similar statement in DB2? I found a similar syntax structure under materialized query tables, but it appeared that the new table would remain tied to the original source in some way. Perhaps I am mistaken?
Create table 2 like table 1;
Insert into table 2 select * from table 1;
Two SQL statements. I don't understand what the big deal is.
DB_2 wrote: I was wondering if there was a way to create a copy of a table in a single SQL statement, together with its column structure and data. In Oracle, there is a "CREATE TABLE new-table AS select-statement" that I can use to accomplish this.
Is there a similar statement in DB2? I found a similar syntax structure under materialized query tables, but it appeared that the new table would remain tied to the original source in some way. Perhaps I am mistaken?
More importantly, is there any way of *completely* duplicating a table:
columns, constraints, indexes, etc., with minimal pain, perhaps into
another schema or database? If not, is there an easy (I realize that
easy is subjective, relative to the knowledge/experience of the
(be)holder thereof) way of getting the names or (in a pleasant world)
the ddl/dml for all the relevant objects? In one swell foop?
> More importantly, is there any way of *completely* duplicating a table: columns, constraints, indexes, etc., with minimal pain, perhaps into another schema or database? If not, is there an easy (I realize that easy is subjective, relative to the knowledge/experience of the (be)holder thereof) way of getting the names or (in a pleasant world) the ddl/dml for all the relevant objects? In one swell foop?
You can use the db2look command to generate the DDL.
To move the data to another database, you can use the export and import
commands, or look at the db2move utility.
For details, please consult the "Command Reference Manual," and/or the "Data
Movement Utilities Guide and Reference."
Mark A wrote: "DB_2" <de*******@yahoo.com> wrote in message news:9b**************************@posting.google.c om... I was wondering if there was a way to create a copy of a table in a single SQL statement, together with its column structure and data. In Oracle, there is a "CREATE TABLE new-table AS select-statement" that I can use to accomplish this.
Is there a similar statement in DB2? I found a similar syntax structure under materialized query tables, but it appeared that the new table would remain tied to the original source in some way. Perhaps I am mistaken?
Create table 2 like table 1; Insert into table 2 select * from table 1;
Two SQL statements. I don't understand what the big deal is.
One could wrap the two statements into a SQL procedure and, thus, just
invoke the procedure from the client in a single statement.
--
Knut Stolze
Information Integration
IBM Germany / University of Jena
There is an option to do this in the DB2 Control Center.
Robert Stearns wrote: DB_2 wrote:
I was wondering if there was a way to create a copy of a table in a single SQL statement, together with its column structure and data. In Oracle, there is a "CREATE TABLE new-table AS select-statement" that I can use to accomplish this.
Is there a similar statement in DB2? I found a similar syntax structure under materialized query tables, but it appeared that the new table would remain tied to the original source in some way. Perhaps I am mistaken?
More importantly, is there any way of *completely* duplicating a table: columns, constraints, indexes, etc., with minimal pain, perhaps into another schema or database? If not, is there an easy (I realize that easy is subjective, relative to the knowledge/experience of the (be)holder thereof) way of getting the names or (in a pleasant world) the ddl/dml for all the relevant objects? In one swell foop? This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Toby Austin |
last post by:
I'm trying to replace <table>s with <div>s as much as possible.
However, I can't figure out how to do the following…
<table>
<tr>
<td valign="top" width="100%">some data that will...
|
by: laurenq uantrell |
last post by:
Is it possible to use With (NOLOCK) and With (READPAST) in the same
SELECT query and what whould be the syntax?
@param int
SELECT
myRow
FROM
dbo.myTable WITH (NOLOCK)
WHERE
|
by: jim |
last post by:
I have two tables that are related by keys. For instance,
Table employee {
last_name char(40) not null,
first_name char(40) not null,
department_name char(40) not null,
age int not null,
......
|
by: Marco Simone |
last post by:
Hi,
What is your opinion about using Lookup field in table. I would like to use
lookup field in table 1, so that I can choose data in combo box from table
2.
Is this good design of database?
...
|
by: Robin S. |
last post by:
**Eric and Salad - thank you both for the polite kick in the butt. I hope
I've done a better job of explaining myself below.
I am trying to produce a form to add products to a table (new...
|
by: Jimmy |
last post by:
I have a table that is shown below in ORIGINAL TABLE. It is common for
the VEHICLE # field to have repeating vehicles (ID 3,4,5 & 8,9).
Usually the Vehicle will have SHIPDATE, DATE_RECEIVED, and...
|
by: MJ |
last post by:
When I look in relationships I find a couple of tables have duplicated
themselves and the titles has an underline and then a number 1 after
them. Do you have any idea what would be causing this? ...
|
by: Macbane |
last post by:
Hello All,
This has been bugging me for too long. I have a database that records
medical interventions. I am familiar with the theory behind
normalisation but am unsure what to do with the...
|
by: ravi |
last post by:
Hi
can anybody tell me that which ds will be best suited to implement a
hash table in C/C++
thanx. in advanced
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
| |