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 (//Build 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
//Below 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 that in the table under construction:
- Set the ID to a number 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.
- Set name to a character field of length 10
- The address is set to a character field of length 50, and the default value is Shenzhen.
- Set year as the Date field.
Notes MySQL instance: Build a table and insert data 2