DBAtlas · データベース運用アトラス

テーブル/コレクションを一覧表示

Oracle

SELECT table_name FROM user_tables ORDER BY table_name;
-- All schemas: SELECT owner, table_name FROM dba_tables ORDER BY owner, table_name;

user_tables は現在のスキーマのテーブル、all_tables はアクセス可能なテーブルを返す。

PostgreSQL

SELECT table_schema, table_name
FROM information_schema.tables
WHERE table_type = 'BASE TABLE' AND table_schema NOT IN ('pg_catalog','information_schema')
ORDER BY 1, 2;
-- psql shortcut: \dt *.*

public スキーマのみの場合: WHERE table_schema = 'public'.

MySQL

SHOW TABLES;
-- Another schema: SHOW TABLES FROM mydb;

詳細: SELECT table_name, table_rows FROM information_schema.tables WHERE table_schema = DATABASE();

SQL Server

SELECT s.name AS schema_name, t.name AS table_name
FROM sys.tables t
JOIN sys.schemas s ON t.schema_id = s.schema_id
ORDER BY s.name, t.name;

ショートカット: SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_TYPE = 'BASE TABLE';

MongoDB

show collections
// or: db.getCollectionNames()

システムコレクションも表示するには: db.getCollectionInfos().

Redis

SCAN 0 MATCH * COUNT 100
# Continue with SCAN <cursor> ... using the returned cursor

Redis には「テーブル」がなく、キーを一覧表示する。本番環境では KEYS * を絶対に使用しないこと(ブロックする)。SCAN はカーソルベース。

DBAtlas で開く →