A simple MySQL database script

Source: Internet
Author: User

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.


    Related Article

    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.