Page 1 of 1
					
				Know if DataBase dont have tables
				Posted: Tue  18 Jul 2006 16:27
				by fsandoval
				Hi for all, I make test with this component but i need to do 2 things. 
1 .- Create a Dabate
2.- How i can know if database is doesnt has tables, for create those.
i working cbuilder.
regards.
fernando sandoval ruiz
			 
			
					
				
				Posted: Wed  19 Jul 2006 06:04
				by Zagawa
				Hi,
For your second question
Code: Select all
select S.`schema_name` from `information_schema`.`schemata` S
where S.`schema_name` not in
( select T.`table_schema`
from `information_schema`.`TABLES` T where
T.`table_schema`=S.`SCHEMA_NAME` )
and S.`schema_name` = 'dbname';
This query will return empty result if 'dbname' doesn't have table.
 
			 
			
					
				
				Posted: Wed  19 Jul 2006 09:33
				by Antaeus
				These are common questions of SQL for MySQL Server usage.
> 1 .- Create a Dabate 
To create database you should execute a command like CREATE DATABASE database_name;
> 2.- How i can know if database is doesnt has tables, for create those.
You should use GetTableNames method of TMyConnection or SHOW TABLES command of MySQL Server. Also you should pay attention on following commands: DROP TABLE IF EXISTS and CREATE TABLE IF NOT EXISTS.
For more information read MySQL Reference Manual.
			 
			
					
				Thanks.
				Posted: Wed  19 Jul 2006 15:04
				by fsandoval
				Many thanks, for you help.