MySQL Study Notes 2: Basic Database Operations

Source: Internet
Author: User

MySQL we have installed is a database management tool. What is really valuable is data.

Relational database data exists in the form of tables, and N tables are aggregated into a database.

Now let's take a look at the basic operations of the database.

There are only three points: Create, delete, and view

 

Create a database
 
MySQL> Create DatabaseSchool; query OK,1Row affected (0.00Sec)

The create database statement is used to create a database, and the database name cannot be changed.

The school is the name of the database, and the semicolon ends.

If the execution is successful, query OK is displayed, and the execution time is also displayed.

When a database is available, the current database is usually viewed.

 

TIPS:When creating a database, it is best to add charset = utf8 at the end to specify the character set. In addition, character set or char set is also effective.

The equal sign is omitted or the default value is added before the statement.

 

Displays the database creation information.
MySQL > Show Create   Database  Test \ G  ***************************   1 . Row ***************************         Database  : Test  Create   Database : Create   Database 'Test'/*  ! 40100 default Character Set utf8  */  1 Row In   Set ( 0.00 Sec)

The show create database statement is used to view the statements used to create a database.

The character set is the default character set.

 

View Database
MySQL >  Show databases;  +  --  ------------------ + |   Database             |  +  --  ------------------ +  | Information_schema |  | MySQL |  | Performance_schema |  | School |  | Test|  +  --  ------------------ +  5 Rows In   Set ( 0.00 Sec)

In this way, the created database is displayed, where school is the one just created

The remaining items exist by default. Do not change them.

Test is used for testing and can be deleted.

 

Delete Database
MySQL> Drop DatabaseSchool; query OK,0Rows affected (0.00Sec)

It's easy to delete. Just run the drop database Command.

Next, you can use show databases to view the effect.

Note that do not forget the semicolon after the statement

 

In practice, we operate more than databases, but tables in databases.

So the content here is very simple.

 

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.