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 (", ' Allen ', ' Dalian One ', ' 1976-10-10′ ');
INSERT INTO teacher values (", ' Jack ', ' Dalian II ', ' 1975-12-23′ ');
It is also possible to type the above commands at the MySQL prompt, but it is not easy to debug. There are two ways to solve this problem:
- You can write the above command as-is to a text file, assume that it is school.sql, then copy it to c:\\, and enter the directory in the DOS state [Url=file://\\mysql\\bin]\\mysql\\bin[/url], and then type the following command:
Mysql-uroot-p Password < C:\\school.sql
If successful, empty a row without any display, and if there is an error, there is a hint. (The above command has been debugged, you can use it only if you remove//comment).
- Alternatively, use mysql> source c:\\school.sql after entering the command line; You can also import the School.sql file into the database.
Notes MySQL instance: Build a table and insert data 1