Show table constraints

This commit is contained in:
Brian Low
2015-12-04 17:14:03 -07:00
parent 4fb24cb229
commit eeb0fdf3a4
8 changed files with 89 additions and 33 deletions

View File

@@ -18,6 +18,16 @@ const (
PG_TABLE_INDEXES = `SELECT indexname, indexdef FROM pg_indexes WHERE tablename = $1`
PG_TABLE_CONSTRAINTS = `SELECT
pg_get_constraintdef(c.oid, true) as condef
FROM pg_constraint c
JOIN pg_namespace n ON n.oid = c.connamespace
JOIN pg_class cl ON cl.oid = c.conrelid
WHERE n.nspname = 'public'
AND relname = $1
ORDER BY contype desc`
PG_TABLE_INFO = `SELECT
pg_size_pretty(pg_table_size($1)) AS data_size
, pg_size_pretty(pg_indexes_size($1)) AS index_size