kellz Posted October 20, 2007 Share Posted October 20, 2007 hey SQL people^^ how can i check if the database "addressbook" already exists before i try to make it? i know there are commands like IF NOT EXIST and IF EXIST but i don't know what order to use them in.. I tried IF NOT EXIST addressbook CREATE DATABASE addressbook but it didn't work lol thx guys! Quote Link to comment https://forums.phpfreaks.com/topic/74094-how-do-you-check-if-a-databse-already-exists/ Share on other sites More sharing options...
Simon Moon Posted October 20, 2007 Share Posted October 20, 2007 CREATE DATABASE IF NOT EXISTS db_name Reference: http://dev.mysql.com/doc/refman/5.0/en/create-database.html Quote Link to comment https://forums.phpfreaks.com/topic/74094-how-do-you-check-if-a-databse-already-exists/#findComment-374139 Share on other sites More sharing options...
derwert Posted October 21, 2007 Share Posted October 21, 2007 If you are using a scripting language then you could also do something along the lines of SHOW databases WHERE `database` = 'db_name' Then use your scripting language to see if anything was returned. Quote Link to comment https://forums.phpfreaks.com/topic/74094-how-do-you-check-if-a-databse-already-exists/#findComment-374597 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.