Application of SQL statements related to Oracle table replication

Source: Internet
Author: User
Tags types of tables

This article describes the SQL statements related to Oracle table replication. This article describes the five types of tables that are frequently used in Oracle table replication SQL, if you are interested in the application of SQL statements related to Oracle table replication, you can browse my article.

As shown in the following figure, Table a is an existing table in the database, and table B is the table to be copied and created based on table:

1. copy only the SQL statements of the Table Structure

 
 
  1. create table b as select * from a where 1<>1 

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

 
 
  1. create table b as select * from a 

3. Copy the SQL statement used to create fields in the table

 
 
  1. create table b as select row_id,name,age from a where 1<>1 

The premise is that row_id, name, and age are all columns in table.

4. SQL statement used to copy the specified fields and data of the specified fields in the Oracle table

 
 
  1. create table b as select row_id,name,age from a 

Although the preceding statements can easily replicate and Create Table B according to the structure of Table a, the index of Table a cannot be copied and must be manually created in table B.

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

 
 
  1. insert into t2(column1, column2, ....)
     select column1, column2, .... from t1 

The above content is an introduction to the SQL statements of Oracle copy tables.

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.