MySQL Create a database and table demo

Source: Internet
Author: User
Tags mysql create

Demo:

Syntax for creating a database
1. Basic grammar
Create DATABASE tour character Set GBK;

Use tour;
Non-primary key self-growing
CREATE TABLE Emb_t_employee
(
Emb_c_operatorid int NOT NULL,
Emb_c_empcode varchar (255) is not NULL,
Emb_c_gender int NOT NULL,
Emb_c_email varchar (255) is not NULL,
Emb_c_empmphone varchar (255) is not NULL,
Emb_c_emptel varchar (255),
Emb_c_empzipcode varchar (50),
Emb_c_emppid varchar (50),
Emb_c_empbirthdate datetime,
Emb_c_empaddress varchar (512),
Emb_c_regdate datetime NOT NULL,
Emb_c_displayorder int NOT NULL,
Primary KEY (Emb_c_operatorid)
) Engine=innodb default CHARSET=GBK;
There is a primary key self-growth does not control the starting point of the primary key
CREATE TABLE Emb_t_dictbustype
(
Emb_c_bustypeid int NOT NULL auto_increment,
Emb_c_bustypeenname varchar (255) is not NULL,
Emb_c_bustypezhname varchar (255) is not NULL,
Primary KEY (Emb_c_bustypeid)
) Engine=innodb default CHARSET=GBK;
Starting point with primary key self-growth control primary key
CREATE TABLE Emb_t_dictbustype
(
Emb_c_bustypeid int NOT NULL auto_increment,
Emb_c_bustypeenname varchar (255) is not NULL,
Emb_c_bustypezhname varchar (255) is not NULL,
Primary KEY (Emb_c_bustypeid)
) Engine=innodb auto_increment=1001 default CHARSET=GBK;
2. View all current Data
show databases;
3. View all tables in the current database
Show tables;
4. View table structure
Desc Emb_t_dictbustype;
5. View Character Set
Show variables like ' collation_% ';
Show variables like ' character_set_% ';
6. Modify the character set of the database
ALTER DATABASE tour character set utf-8;

Copyright Source: http://www.blogjava.net/sxyx2008/

MySQL Create a database and table demo

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.