Three ways to add SQL Server Basic operations

Source: Internet
Author: User

Objective:

Database operation can not avoid the operation of the data, the operation method is similar, original aim, write a variety of flower operation of the fundamental additions and deletions to check four operations, today we will say three ways to increase the operation

Body:

Adding a data row to a database adds new data information

Precautions:

1. Insert the data row to insert the complete, do not insert only a few columns

2. The data type, precision, and scale of each value must match the corresponding column;

3. You cannot specify a value for an identity column because its number is automatically increased;

4. When inserting to conform to the constraint

5. Columns with default values, you can use the default (default) keyword instead of the inserted value

  

Format:

(1) INSERT [into] < table name > [column Name] Values < value list >

  

Cases:

INSERT VALUES ('s001',' Zhang San ',' male '), ('  s002',' John Doe ', ' male ')

(2) INSERT into < table name > (column name) SELECT < column name > from < source table name >

Precautions:

1. The first table must be present

2. You can add multiple

Cases:

INSERT  into table1 (A1,B1,C1) SELECT A2,B2,C2  from Table2
(both Table1 and table2 exist)

(3) SELECT (column name) into < table name > from < source table name >

    

Precautions:

1. The first table name must not exist because the table is automatically built when inserted and the data from the source table is copied to the newly created table

2. Can only be added once, cannot be added repeatedly

Cases:

SELECT (A4,B4,C4)  into Table3  from   Table4 (table3 not present, a4,b4,c4 in Table4)

    

      

      

Three ways to increase SQL Server Basic operations

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.