[SQL] common basic MySQL statements (in progress)

Source: Internet
Author: User

I. Basic Database Operations

1. Create a database
Create database is used to create a database. The basic syntax is as follows:

 

CREATE DATABASE database_name

The following is an example:

 

We want to create a database named "test_db.

We use the following create database statement:

CREATE DATABASE test_django

 

You can use create table to add database tables.


2. view the database

After the creation, we can use the following syntax to view the databases in MySQL (note that there is a last S)

 

SHOW DATABASES

In this way, we can see all the databases in MySQL:

 

At this time, we can see that in addition to the test_django database we created, there are three databases that come with MySQL:

The first database information_schema: provides a way to access database metadata.
MySQL is the core database of MySQL. It is mainly responsible for storing the control and management information required by MySQL, such as database users, permission settings, and keywords. It cannot be deleted. If you are not familiar with MySQL, we recommend that you do not modify the table information in the database.
The third database is test: A test database created during installation. It is named like a completely empty database and can be deleted without any tables.


3. delete a database
The syntax for deleting a database is similar to that for creating a database. The drop syntax is used:

 

DROP DATABASE test

After deletion, we can use show databases to view all the databases. We can see that the test database has been deleted.

 



 

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.