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