SQL replication Features

Source: Internet
Author: User

1. Requirements: Copy all data from a id= ' 1 ' in the table T_user

(1) Premise: There is no primary key in the table

Statement: INSERT INTO T_user select * from T_user where id= ' 1 ' or

Insert into T_user (id,name,sex) Select from Id,name,sex from T_user where id= ' 1 '

Results: There were two identical data of id= ' 1 ' in the table;

(2) Premise: ID is primary key

Statement: (set SqlParameter parameter when. NET link SQL Server) insert into T_user select @Id, name,sex from T_user where id= ' 1 ', @Id pass appropriate arguments

Results: There are two data in the table except the IDs, the other columns are the same;

2. Requirements: Copy part of id= ' 1 ' data from table T_user

Statement: INSERT INTO T_user select Id,name,' 1 ' from T_user where id= ' 1 '

3. Requirements: Copy some of the information in table T_course to the T_user table

Statement: INSERT INTO T_user (id,name,sex) Select @Id, name,sex from T_course where XXXX

SQL replication Features

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.