T-SQL additions and deletions change operation

Source: Internet
Author: User

T-SQL

1. Create a table

CREATE TABLE Car
(
Code varchar (primary key),
Name varchar (NOT NULL),
Time Date,
Price float,
Brand varchar (references) brand (Code)
);

CREATE TABLE Brand
(
Code varchar (primary key),
Name varchar (50)
);

CREATE TABLE Pinpai
(
Ids int Auto_increment primary KEY,
Name varchar (50)
);

Primary KEY Primary Key

Not NULL non-null

References references

Auto_increment Self-growth

Note: All symbols must be in the English state

Add a semicolon after each table is created

Do not add a comma after the last column in the table is finished

To delete a table:
drop table Pinpai


Data manipulation: crud operations additions and deletions

1. Add Data:

INSERT into Brand values (' b001 ', ' BMW 5 '); #第一种方式

INSERT into Brand values (' b002 '); #第二种方式

Insert into Pinpai (Name) VALUES (' VW '); #处理自增长列

INSERT into Pinpai values (' ', ' Volkswagen '); #处理自增长列

2. Most simple query

SELECT * FROM Pinpai #查询所有数据

SELECT * from Pinpai where Ids = 1; #根据条件查询

3. Modifications

Update Pinpai Set Name = ' Porsche ' where Ids = 4; #修改某一条数据

Update Car Set Name = ' Harvard ', time = ' 2012-3-4 ', price = +, Brand = ' b002 ' where Code = ' c001 '

4. Delete data

Delete from Brand #删除所有数据

Delete from Pinpai where Ids = 4; #根据条件删除数据

T-SQL additions and deletions change operation

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.