how to check if a database has been created

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

how to check if a database has been created

Post by davidklonski »

Hello

Is it possible to test if a certain database has been created using SQL?
if so, how can it be done?
The query is obvisouly on the MySQL level and not on a certain database.

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

SHOW STATUS TABLE LIKE 'tablename'
or

Code: Select all

CREATE TABLE IF NOT EXISTS .........
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

Post by davidklonski »

doesn't that test the status of a table?
I was looking for a way of knowing whether a DATABASE exists

thanks
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

hmm I could have swore you said table.. :oops:

Code: Select all

SHOW DATABASES їLIKE 'pattern']
davidklonski
Forum Contributor
Posts: 128
Joined: Mon Mar 22, 2004 4:55 pm

Post by davidklonski »

thanks for the help
Post Reply