Skip to content

Instantly share code, notes, and snippets.

@xivSolutions
Last active August 29, 2015 13:57
Show Gist options
  • Save xivSolutions/9593309 to your computer and use it in GitHub Desktop.
Save xivSolutions/9593309 to your computer and use it in GitHub Desktop.
PG Determine if Column is Auto-Incrementing serial ID
SELECT (CASE (
(SELECT CASE (LENGTH(pg_get_serial_sequence('artist', 'artist_id')) > 0) WHEN true THEN 1 ELSE 0 END) +
(SELECT CASE (SELECT pgc.relkind FROM pg_class pgc WHERE pgc.relname = 'artist' || '_' || 'artist_id' || '_' || 'seq') WHEN 'S"' THEN 1 ELSE 0 END))
WHEN 0 THEN false ELSE true END) AS IsAuto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment