+ 1

How to check if table exist in mysql

How to check if table exits in mysql

16th Nov 2020, 8:17 AM
Shariff
Shariff - avatar
6 Respostas
+ 8
By using the command "SHOW TABLES" in the known database. OR SELECT *FROM Table2. (where Table2 is the table whose existence u want to check.) OR SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '[database name]' AND table_name = '[table name]';
16th Nov 2020, 8:27 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 6
Shariff Wlcm.
16th Nov 2020, 8:47 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 3
For show all tables ==> Show tables ; Or For search by name ==> show tables like 'yourTableName';
17th Nov 2020, 8:03 PM
HAMYD KHADDA
HAMYD KHADDA - avatar
+ 1
Alphin K Sajan how will you execute this from PDO SELECT COUNT(*) FROM information_schema.tables WHERE table_schema = '[database name]' AND table_name = '[table name]'; will this return Boolean ? and can we execute this query in PDO?
16th Nov 2020, 8:43 AM
Shariff
Shariff - avatar
+ 1
Thanks, it was helpful , let me check it out
16th Nov 2020, 8:46 AM
Shariff
Shariff - avatar