12-1 a.m. MySQL Basic statement

Source: Internet
Author: User

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

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.