MySQL database entry (database creation and table creation) -- Chen yuanbo and mysql Chen yuanbo

Source: Internet
Author: User

MySQL database entry (database creation and table creation) -- Chen yuanbo and mysql Chen yuanbo
Create databases and tables1. database creation

(1) SQL statement Command database creation:

Create database Name (encoding garbled characters are not set for the database created by this method)

1

2

3

4

5

-- Set the database encoding method when creating a database

-- Character set: Specifies the character set used by the database. UTF-8 cannot be written as UTF-8.

-- COLLATE: Specifies the sorting rule of the database character set. The default sorting rule of utf8 is utf8_general_ci (viewed through show character set)

Drop DatabaseIf EXISTS dbtest;

Create DatabaseDbtestCHARACTER SETUtf8COLLATEUtf8_general_ci;

 

Modify the database code:

Alter DatabaseDbtestCHARACTER SETUtf8COLLATEUtf8_general_ci;

The following uses the sqlyon GUI as an example to create a database:

 

 

 

 

(2)Graphical Database creation operation: Right-click Database on the left-side-Create Database

 

To avoid Chinese garbled characters in the database in the future, you need to set the database character set to utf8.

2. Create a table

(1)SQL statement command to create a table:

Create table Name (

Column name data type (length ),

Column name data type (length)

);

For example:

Create table test (

Id INT,

Username VARCHAR (20 ),

Age INT (4)

)

Note: The int type does not need to be written. The default value is 11 characters. The length of the string must be specified and separated by commas.

 

(2)Create a graph table:

Right-click Database ----- create --- table

 

The above is a preliminary explanation of the MySQL database creation and table creation methods. If there are any unreasonable reasons, please forgive me and correct me.

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.