Copy SQL data from the same table

Source: Internet
Author: User
The same table data replication may be required in the project. For example, the two records except the date and rowid (automatic number) have the same data. The general method is to read the data and insert it in, even if two SQL statements are executed in the stored procedure, the efficiency is relatively low. Copy data with one statement: Insert   Into New_table_name (column1, column2, column3, column4) Select Column1, column2, column3, column4 From Table_name Where ...

New_table_name and table_name point to the same table, so that the same table can be copied. However, some data may need to be copied. In addition, parameters such as getdate () need to be input, which can be as follows:

Insert   Into Table_name (column1, column2, column3, column4, column5, column6) Select Column1, column2, column3, column4, Getdate (), ' Test '   From Table_name Where ...

Solve the problem !! Note that the field corresponds to the Data Type !!

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.