0

I'm trying to retrieve some table's structures with the column default values using this query :

SELECT column_name, is_nullable, character_maximum_length, udt_name, default_value
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'USER'
ORDER BY ordinal_position

But I'm unable to find the correct value to select the default values. I tried "default_value" but it doesn't work...

1
  • Do you really have a table named USER - that is a bad idea as user is a keyword and the name of a built-in function as well. Commented Aug 9, 2019 at 9:21

1 Answer 1

5

As documented in the manual the default value is available in column_default

SELECT column_name, is_nullable, character_maximum_length, udt_name, column_default
FROM information_schema.columns
WHERE table_schema = 'public'
AND table_name = 'USER'
ORDER BY ordinal_position
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.