author avatar

vaibhav.yadav

Wed Apr 24 2024

We can check the default value for a given column using postgres query like this:

SELECT column_name, column_default
FROM information_schema.columns
WHERE table_name = '<table_name_placeholder>' AND column_name = '<column_name_placeholder>';

Same can be used for constraints like is_nullable as following:

SELECT column_name, is_nullable
FROM information_schema.columns
WHERE table_name = '<table_name_placeholder>' AND column_name = '<column_name_placeholder>';

#database #postgres #query