TomJ
TomJ

Reputation: 1813

MySQL query to check whether a table is in the database or not

I want to check whether a table is in the database or not. So what is the MySQL query to check whether a table is in the database or not ?

Upvotes: 0

Views: 1260

Answers (3)

Deepak Sharma
Deepak Sharma

Reputation: 4170

you should try with database_name and table_name also..

SELECT count(*)
FROM information_schema.tables
WHERE table_schema = 'db_name'
AND table_name = 'table_name'

will return you 1 if exists else 0

Upvotes: 1

sumit
sumit

Reputation: 15464

SELECT count(*)  FROM information_schema.TABLES where TABLE_SCHEMA='dbname' and table_name='tblname'

Upvotes: 0

port5432
port5432

Reputation: 6403

SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = 'MyDataBase'

Upvotes: 1

Related Questions