One. Instance.
Drop database if exists school; Delete if school is present
Create Database School; Building a library School
Use school; Open Library School
CREATE TABLE teacher//Create tables Teacher
(
ID int (3) auto_increment NOT null primary key,
Name Char (TEN) is not NULL,
Address varchar (+) Default ' Shenzhen ',
Year Date
); End of Build table
Desc teacher;//query Table structure.
The following is the Insert field
Insert into teacher values (' ' ', ' Glchengang ', ' Shenzhen One ', ' 1976-10-10 ');
Insert into teacher values (' ' ', ' Jack ', ' Shenzhen One ', ' 1975-12-23 ');
Note: In the table under construction
1. Set the ID to a numeric field of length 3: Int (3), and let it automatically add one to each record: auto_increment, and cannot be empty: NOT NULL, and let him be the main field primary key.
2. Set name to a character field of length 10
3. Set address as the character field of length 50, and the default value is Shenzhen.
4. Set year as the Date field.
Two. Command:
Table Operation Commands:
Duplicate table structure: CREATE TABLE table1 like table2;
Copy data: INSERT INTO table1 select * from table2;
Clear Data sheet: TRUNCATE TABLE t1;
MySQL Database Build List instance