MySQL determines whether a database or table exists

Source: Internet
Author: User

(1) To determine the existence of the database, delete:

Drop database if exists db_name;
(2) to determine the existence of the data table, delete:

drop table if exists table_name;

NOTE: db_name, table_name can be used to "(1 keys next to the key) is caused by the number, also do not cause.


(1) If a simple display of the existence of a database, you can use show databases like ' Db_name ';(2) simply show if there is a data table, you can use show tables like ' table_name '; Note: db_name here, table_name must be caused by ' (single quote).

MySQL determines whether a database or table exists

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.