Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Testing if database exists SQLServer/MySQL

Author  Topic 

HockeyFan
Starting Member

26 Posts

Posted - 2005-12-09 : 13:15:38
I have a general idea of how to test to see if a database exists with SQL Server.

Is there an equivalent with MySQL? How close is the syntax?

Select 1 from Information_Schema.Schemata where catalog_name='mydatabase'

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2005-12-09 : 19:02:39
try to post your question over in [url]http://www.dbforums.com[/url] MySQL forum. This is a MS SQL forum

-----------------
[KH]

Where Am I ?
Go to Top of Page

eyechart
Master Smack Fu Yak Hacker

3575 Posts

Posted - 2005-12-09 : 21:53:24
MySQL < version 5 doesn't have an information schema. Try the following though:


For MySQL < 5

SHOW DATABASES LIKE '%Database Name%';



For MySQL >= 5 the following will work:

SELECT SCHEMA_NAME 
FROM INFORMATION_SCHEMA.SCHEMATA
WHERE SCHEMA_NAME = 'Database Name';


Something like that should work.



-ec

Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2005-12-10 : 15:25:25

its
http://dev.mysql.com/
Go to Top of Page
   

- Advertisement -