Using SQL to manipulate the MySQL database

Source: Internet
Author: User
Tags create database mysql database

The various SQL statements are formally introduced from this section. This section describes SQL at the database level and related operations, viewing, building, and deleting.

Show the existing database by showing

Syntax: Show DATABASES [like Wild]

If you use the like wild section, the wild string can be a string that uses the SQL "%" and "_" wildcard characters.

Features: Show databases lists the databases on the MySQL server host.

You can try the following examples to observe the output, for example:

Mysql>show databases;

+----------+

| Database |

+----------+

| A |

| MySQL |

| MyTest |

| Test |

| Test1 |

+----------+

mysql>show databases like ' my% ';

+----------------+

| Database (my%) |

+----------------+

| MySQL |

| MyTest |

+----------------+

You can also get a list of existing databases using the Mysqlshow program.

Creating a database with Create Dabase

Syntax: CREATE DATABASE db_name

Function: Create database creates a data base with the given name.

An error occurred if the database already exists.

The database in MySQL is implemented as a directory containing the files in the corresponding database tables. Because the database was initially created without any tables, the CREATE DATABASE statement simply creates a directory below the MySQL data directory.

For example:

Mysql>create database Myfirst;

Then use show databases to observe the effect.

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.