LoginSignup
6
5

More than 5 years have passed since last update.

Cloud Spannerでテーブル一覧を取得する

Posted at

ドキュメント読んでも、InstancesのListやDatabaseのListを取るAPIはあるけど、table一覧はなさそう。
MySQLでいうところの SHOW TABLES;みたいなやつはないのかと調べたら、以下のようなクエリで取れました。

SELECT
  t.table_name
FROM
  information_schema.tables AS t

空のDatabaseに対してやると、以下のようなtableが取得できます。

COLUMNS
COLUMN_OPTIONS
INDEXES
INDEX_COLUMNS
SCHEMATA
TABLES

上記のデフォルトで作られるtableを除いて、ユーザが作ったテーブルだけ取得したい場合は以下のようなクエリになります。

SELECT
  t.table_name
FROM
  information_schema.tables AS t
WHERE
  t.table_catalog = '' and t.table_schema = ''

これ探すの苦労したけど、ドキュメントに思いっきり書いてあった
Information Schema  |  Cloud Spanner Documentation  |  Google Cloud

6
5
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
6
5