Tim Partridge
Tim Partridge

Reputation: 3393

Can the INFORMATION_SCHEMA schema be used to check if a database exists?

There are alternative ways to detect database existence, but can the INFORMATION_SCHEMA schema be used instead (such as in the master db, or somewhere else)?

Upvotes: 0

Views: 1422

Answers (2)

Adam Robinson
Adam Robinson

Reputation: 185643

No; as you can see from all of the views defined in the INFORMATION_SCHEMA namespace, the views contained therein are specific to a single database, so nothing database-agnostic (such as a list of databases) is provided. You'll have to use the ordinary system views as described in your linked question/answer to do that.

Upvotes: 2

Joe Stefanelli
Joe Stefanelli

Reputation: 135809

As far as I know, this is not possible with INFORMATION_SCHEMA. As noted in the documentation, INFORMATION_SCHEMA is created on a per database basis, and contains metadata specific to the database it is created in. There is no concept of a "server level" INFORMATION_SCHEMA.

Upvotes: 2

Related Questions