SQL to get the schema list (Oracle / MySQL / PostgreSQL / SQLServer / Cassandra)

Introduction

MiluDB Viewer (GUI DB client using JavaFX) I forgot what I made when I made it, so make a note of it.

This time, it is about SQL to get the schema list.

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 other than the above

As I learned later, if JDBC implements it, In the getSchemas () method of java.sql.DatabaseMeataData, Since java.sql.ResultSet is returned, You can get it with resultset.getString ("TABLE_SCHEM").

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

Recommended Posts

SQL to get the schema list (Oracle / MySQL / PostgreSQL / SQLServer / Cassandra)
SQL to get table list (Oracle / MySQL / PostgreSQL / SQLite / SQLServer / Cassandra)
Sample code to get the values of major SQL types in Java + MySQL 8.0
Sample code to get the values of major SQL types in Java + Oracle Database 12c
Rails DB PostgreSQL changed to MySQL
What you did to get the Oracle Certified Java Programmer, Silver SE 8