Results 1 to 2 of 2
  1. #1
    Join Date
    Dec 2005
    Posts
    12

    Unanswered: test if a database exists in MySQL

    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'

  2. #2
    Join Date
    Feb 2005
    Location
    Germany
    Posts
    22
    hi,
    to get an idea of how to test this, do an export with "mysqldump user/password -opt --all-databases > db_create.sql". This tools generates a script to recreate the database. It also includes "if exist" statements, to do a drop if necessary.
    I hope this will give you the needed statements.

    The actual db names are listed with "show databases".
    Martin

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •