列出表 / 集合
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 返回当前 schema 中的表,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 schema: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 cursorRedis 没有“表”;列出的是键。生产环境中切勿使用 KEYS *(会阻塞);SCAN 基于游标。