Skip to content

Instantly share code, notes, and snippets.

@ycku
Last active February 9, 2021 05:38
Show Gist options
  • Save ycku/4b67cd39a9b9c9e5f6897cf1c3061e75 to your computer and use it in GitHub Desktop.
Save ycku/4b67cd39a9b9c9e5f6897cf1c3061e75 to your computer and use it in GitHub Desktop.
列出資料庫中的 Primary key
SELECT s.schemaname,
s.indexname
FROM pg_index i
JOIN pg_indexes s
ON i.indexrelid = ( s.schemaname||'.'||s.indexname ) :: regclass :: oid
WHERE i.indisprimary = TRUE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment