-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostgresql.sql
More file actions
24 lines (19 loc) · 1.14 KB
/
postgresql.sql
File metadata and controls
24 lines (19 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
SELECT * FROM information_schema.tables WHERE table_schema = 'public' AND table_name NOT LIKE '%_ref_sys' AND table_type <> 'VIEW';
SELECT * FROM information_schema.columns WHERE table_name ='road_event_standard';
SELECT c.relname As tname, CASE WHEN c.relkind = 'v' THEN 'view' ELSE 'table' END As type,
pg_get_userbyid(c.relowner) AS towner, t.spcname AS tspace,
n.nspname AS sname, d.description
FROM pg_class As c
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
LEFT JOIN pg_description As d ON (d.objoid = c.oid AND d.objsubid = 0)
WHERE c.relkind IN('r', 'v') AND d.description > ''
ORDER BY n.nspname, c.relname;
SELECT a.attname As column_name, d.description
FROM pg_class As c
INNER JOIN pg_attribute As a ON c.oid = a.attrelid
LEFT JOIN pg_namespace n ON n.oid = c.relnamespace
LEFT JOIN pg_tablespace t ON t.oid = c.reltablespace
LEFT JOIN pg_description As d ON (d.objoid = c.oid AND d.objsubid = a.attnum)
WHERE c.relkind IN('r', 'v') AND n.nspname = 'public' AND c.relname = 'road_event_standard'
ORDER BY n.nspname, c.relname, a.attname;