Possible Duplicate:
SELECT INTO using Oracle
I have came across SQL SELECT INTO
statement for creating new table and also dumping old table records into new table in single SQL statement as
SELECT * INTO NEW_TABLE FROM OLD_TABLE;
But when i am trying the above query it is giving error as ORA-00905: missing keyword
Is it possible to do that in ORACLE ?
Thanks.
Use Transact-SQLRight-click the table you wish to duplicate, point to Script Table as, then point to CREATE to, and then select New Query Editor Window. Change the name of the table. Remove any columns that are not needed in the new table. Select Execute to create the new table.
The SELECT INTO statement creates a new table and inserts rows from the query into it. If you want to copy the partial data from the source table, you use the WHERE clause to specify which rows to copy.
If you would like to create a new table, the first step is to use the CREATE TABLE clause and the name of the new table (in our example: gamer ). Then, use the AS keyword and provide a SELECT statement that selects data for the new table.
The SQL INSERT INTO SELECT Statement The INSERT INTO SELECT statement copies data from one table and inserts it into another table. The INSERT INTO SELECT statement requires that the data types in source and target tables match. Note: The existing records in the target table are unaffected.
The syntax for creating a new table is
CREATE TABLE new_table AS SELECT * FROM old_table
This will create a new table named new_table
with whatever columns are in old_table
and copy the data over. It will not replicate the constraints on the table, it won't replicate the storage attributes, and it won't replicate any triggers defined on the table.
SELECT INTO
is used in PL/SQL when you want to fetch data from a table into a local variable in your PL/SQL block.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With