Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to query the existence of data tables by mysql

2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly shows you "mysql how to query the existence of the data table", the content is easy to understand, clear, hope to help you solve the doubt, the following let the editor lead you to study and learn "mysql how to query the existence of the data table" this article.

In mysql, you can use the "select from" statement to query the existence of a specified data table, with the syntax "select*from information_schema.TABLES where TABLE_NAME = 'name of the data table to be queried';".

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

How to use SQL query statements to determine whether databases and tables exist?

1. Judge whether the database exists.

The query SQL is as follows:

Select * from information_schema.SCHEMATA where SCHEMA_NAME = 'database name to be found'

You can also fuzzy query. The SQL is as follows:

Select * from information_schema.SCHEMATA where SCHEMA_NAME like'% partial name of the database name to be queried%'

2. Judge whether the data table exists or not

The query SQL is as follows:

Select * from information_schema.TABLES where TABLE_NAME = 'name of the data table to be queried'

You can also fuzzy query. The SQL is as follows:

Select * from information_schema.TABLES where TABLE_NAME like'% partial name of the data table name to be queried. The above is all the contents of the article "how to query the data table for the existence of mysql". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report