CREATE TABLE Test
(
Code varchar (primary key),
Name varchar (20)
);
Key words
Primary KEY Primary Key
Non-empty NOT NULL
Foreign key (column name) references primary table name (column name) foreign key
Federated primary KEY (the table cannot find a primary key)
Self-growing column auto_increment (the table cannot find the primary key)
Note: 1. Add a semicolon after each statement, 2. The last column does not add a comma 3. If the symbol is Chinese
CREATE TABLE Test
(
Code varchar (primary key),
Name varchar (NOT NULL)
);
Create TABLE Zhu
(
code int (primary key),
Name varchar (20)
);
CREATE TABLE Cong
(
code int (primary key),
Name varchar (20),
Zhu Int,
Foreign key (Zhu) references Zhu (code)
);
CREATE TABLE Haoyou
(
IDS int Auto_increment primary KEY,
Me varchar (20),
Friends varchar (20)
)
Homework
1. Modifying table statements
Two pairs of data to be deleted and changed to find Crud
Add Data:
Insert into table name values (' ', ');
Insert into table name (column name) values (");
Note: 1. If the added data is a string, you need to add ' ', other types do not add.
2. When adding data, it's worth the number to match the number of columns.
3. Add a single piece of data insert into table name (column name) values (");
4. If the column you want to add is a self-growing column, you can give a null value
12-1 a.m. MySQL Basic statement