A simple MySQL database script
During this time, I learned about the MySQL database because of the project, and posted a MySQL script for creating databases, data tables, and users to share with you.
<Br/> -- create database <br/> -- <br/> create database if not exists new_db Character Set = 'gb2312 'collate = 'gb2312 _ chinese_ci'; <br/> -- Create Table <br/> -- <br/> Use new_db; <br/> drop table if exists customer; <br/> Create Table customer <br/> (<br/> customerid smallint unsigned not null primary key auto_increment, <br/> name varchar (20) not null, <br/> gender Enum ('M', 'F') not null,/* m-> male, F-> female */<br/> address varchar (25) not null default '', <br/> telephone smallint unsigned not null default '0' <br/>) engine = InnoDB default charset = gb2312 default collate = gb2312_chinese_ci; <br/> Use new_db; <br/> drop table if exists testinginfo; <br/> Create Table testinginfo <br/> (<br/> testingid smallint unsigned primary key not null auto_increment, <br/> customerid smallint unsigned not null, <br/> city varchar (20) not null default '', <br/> curdate date not null default 0, <br/> checkin Enum ('T ', 'N') not null,/* t-> true, N-> not */<br/> groups Enum ('A', 'B', 'C ') not null, <br/> foreign key (customerid) References customer (customerid) <br/>) engine = InnoDB default charset = gb2312 default collate = gb2312_chinese_ci; <br/> -- creata user <br/> -- <br/> Use new_db; <br/> grant select, insert, update, delete on new_db. * To M1 @ '%', m2 @ '%', M3 @ '% ';
For more information about the syntax, see the MySQL documentation.