|
|
Using Information schema to check if a MySQL table exists - Mysql
|
Views : 372
|
|
Tagged in : Mysql
|
|
|
Report This Scrap as Inappropriate We request you to choose the appropriate categroy and subcategory that suits your
objectionable concern about the scrap, So that our team can review and find out whether it violates our Guidelines or the
scrap is not suitable for all viewers.
|
From MySQL 5.0 there is an information schema database which contains the information about the databases. This database can be used to determine various information, including whether or not a table exists in a given database in MySQL.
Syntax
SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = '[database name]'
AND table_name = '[table name]'
Example
SELECT COUNT(*)
FROM information_schema.tables
WHERE table_schema = 'test'
AND table_name = 'test1';
|
|
By Rekha, On - 2010-01-28 |
|
|
|