SQL statement used to copy a table from Oracle

Source: Internet
Author: User

1. copy only the SQL statements of the Table Structure

Create Table tablename2 as select * From tablename1 where 1 <> 1

2. SQL statement used to copy the table structure and data in the table

Create Table tablename2 as select * From tablename1

 

3. SQL statement used to create fields for Oracle replication tables

Create Table tablename2 as select row_id, name, age from tablename1 where 1 <> 1 // The premise is that row_id, name, age are all columns of Table.

 

4. Copy the specified fields of the table and the SQL statement of the data of these specified fields

Create Table tablename2 as select row_id, name, age from tablename1

Although the preceding statements can easily create tablename2 tables based on tablename1 table structure replication, the indexes of tablename1 tables cannot be copied and must be manually created in tablename2.

 

5. Insert into saves the query result to an existing table.

Insert into tablename2 (column1, column2,...) (select column1, column2,... from tablename1)

 

.....

 

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.