How can easily copy a selection op data (structure and data)

How can easily copy a selection op data (structure and data)

am 24.10.2005 11:43:41 von David Kirkby

How can easily copy a selection op data (structure and data)
I would like to copy the result of a query to a new table.
The query consist of several different tables

Albert

Re: How can easily copy a selection op data (structure and data)

am 24.10.2005 12:41:07 von Hilarion

> How can easily copy a selection op data (structure and data)
> I would like to copy the result of a query to a new table.
> The query consist of several different tables


This creates a new table based on the SELECT structure (column
names and types - this does not apply any constraints to the
new table, including primary key constraint):

CREATE TABLE new_table AS
SELECT some_columns
FROM some_tables
WHERE some_expressions


This only inserts bulk of data into a table using a select:

INSERT INTO existing_destination_table ( destination_columns )
SELECT source_columns
FROM source_tables
WHERE some_expressions


Hilarion


PS.: It may not work in some DBMS engines but should work in most
of them.