Skip to content

Instantly share code, notes, and snippets.

@le0pard
Created April 8, 2011 21:11
Show Gist options
  • Save le0pard/910749 to your computer and use it in GitHub Desktop.
Save le0pard/910749 to your computer and use it in GitHub Desktop.
Return default value of field in table
CREATE OR REPLACE FUNCTION ret_def(text,text,text) RETURNS text AS $$
SELECT
COLUMNS.column_default::text
FROM
information_schema.COLUMNS
WHERE table_name = $2
AND table_schema = $1
AND column_name = $3
$$ LANGUAGE sql IMMUTABLE;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment