12
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

スキーマ一覧を取得するSQL(Oracle/MySQL/PostgreSQL/SQLServer/Cassandra)

Posted at

#はじめに

MiluDBViewer(JavaFXを使ったGUI DBクライアント)
作ったときの内容を忘れてきたのでメモします。

今回は、スキーマ一覧を取得するSQLについてです。

Oracle - 12c Release2

select distinct owner from all_objects order by owner

MySQL - 8.0.11

select schema_name from information_schema.schemata order by schema_name

PostgreSQL - 10.4

select schema_name from information_schema.schemata order by schema_name

SQLServer - 2017

select name from sys.schemas order by name

Cassandra - 3.9.0

select keyspace_name, durable_writes from system_schema.keyspaces

上記以外のDB

後から知ったのですが、JDBCが実装していれば、
java.sql.DatabaseMeataDataのgetSchemas()メソッドで、
java.sql.ResultSetが返ってくるので、
resultset.getString("TABLE_SCHEM")でとれます。

参考URL
http://www.java2s.com/Tutorial/Java/0340__Database/GettableinformationfromDatabaseMetaData.htm

12
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
12
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?