Using Information schema to check if a MySQL table exists - Mysql Views : 372
Tagged in : Mysql
0 0
Send mail
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



    Login to add Comments .