473,395 Members | 1,568 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

MySql: does a database exist?

I know how to do this in SQL Server, but need the equivalent query to determine if a database exists in MySql.

In SQL Server, the query is:
Select 1 From Information_Schema.Schemata
Where Catalog_Name='whatevermydatabaseisnamed'

I'm not that familiar with MySQL, but betting the statement is different.
Dec 9 '05 #1
2 5618
Niheel
2,460 Expert Mod 2GB
Can you explain the query in english. I don't understand Information_Schema.Schemata. Is that the name of a table? Is Catalog_Name, the column?
Dec 9 '05 #2
Information_Schema.Schemata is actually a view
Information_Schema is the owner and Schemata is the view
Catalog_name is the database name
This is a canned view in SQLserver.

It is the following code:
Expand|Select|Wrap|Line Numbers
  1. select
  2.     db.name                        as CATALOG_NAME
  3.     ,USER_NAME()                as SCHEMA_NAME
  4.     ,USER_NAME()                as SCHEMA_OWNER
  5.     ,convert(sysname, NULL)        as DEFAULT_CHARACTER_SET_CATALOG
  6.     ,convert(sysname, NULL)        as DEFAULT_CHARACTER_SET_SCHEMA
  7.     ,a_cha.name                    as DEFAULT_CHARACTER_SET_NAME
  8. FROM
  9.     master.dbo.sysdatabases         db,
  10.     master.dbo.syscharsets        a_cha --charset/1001, not sortorder.
  11. WHERE
  12.     a_cha.type = 1001 --- type is charset
  13.     AND a_cha.id = convert(tinyint, DatabasePropertyEx(db.name, 'sqlcharset'))
Dec 9 '05 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Jan | last post by:
I store sql-commands in a database table. In the first step I get the sql command out of the database table with embedded sql. In the second step I try to execute the command, which i got from the...
4
by: Robert Rae | last post by:
OS XP Pro SP2 MYSQL Ver: 5.0.0-alpha nt Whenever I view a table or run a query in the Control Center (0.9.4-beta) I get the following error: ERROR 1146: Table 'shipnet.1' doesn't exist ...
2
by: adam | last post by:
hello What query shoul I send to SQL serwer ( in transact SQL language ) to check does some database exist on serwer ? It similar to problem "does some table exist in database" - resolve to it...
0
by: Dirk Försterling | last post by:
Hi all, a few days ago, I upgraded from PostgreSQL 7.2.1 to 7.4, following the instructions in the INSTALL file, including dump and restore. All this worked fine without any error (message). ...
2
by: george r smith | last post by:
Gentlemen, I know that this problem has happened before and I searched and tried all solutions but problem is not solved. I install asp.net community starter kit with some help from this...
6
by: Bob | last post by:
Having trouble getting started. I created an instance of MSDE called VSDOTNET on a computer with the name of sysdev. Using MS SQL Web Adminstrator I created a database called temp with a...
3
by: Olivogt | last post by:
Hello, I was just puting an application on the web server but it did not work as usual... - I do develop on my notebook and move released applications to the Web server - both have Sql Server...
1
by: ssp | last post by:
G'Day All, I have a web application sitting on my laptop and a Sql Server 2000 database on our INTRANET server running Windows 2003. Up until recently I was able to access the database using my...
5
by: Blessy | last post by:
Before restarting my server i was able to access my local database.When I restarted the server it is giving the following error. ORA- 01034 : ORACLE not available ORA-27101 : shared memory...
3
by: moltendorf | last post by:
I copied the files from my "test" database on my old server (MySQL was not running) to my new server ("./mysql/data/test" folder), and after starting the server, SHOW TABLES; shows all of the tables...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.