Database statement-based table creation, data table copying, and statement copying

Source: Internet
Author: User

Database statement-based table creation, data table copying, and statement copying
1. Database tabulation statements

Create table tb_People (id integer primary key, Name varchar (255), Sex varchar (255 ))
2. Copy data tables from the same database
SQL: insert into table1 select * from table2 (full copy) insert into table1 select distinct * from table2 (no duplicate copy ); insert into table1 select top 10 * from table2 (first 10 copies)
3. Copying data tables in different databases

DB1 and DB2 are two databases, tb_boy and tb_girl are the tables of the first two databases respectively.
SQL:

Insert into DB1.tb _ boy select * from DB2.tb _ girlinsert into DB1.tb _ boy select * from DB2.tb _ girl (full copy) insert into DB1.tb _ boy select distinct * from DB2.tb _ girl (no duplicate copy); insert into DB1.tb _ boy select top 10 * from DB2.tb _ girl (first 10 copies)

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.