This article is half-done without your Comment! *** Please share your thoughts via Comment ***
In this post, I am sharing one script to find all default values of the PostgreSQL columns.
Sometimes, it is required to find out default values of a column which is creating a problem in the data.
You can easily find default values in the table definition script, but if you require to report all default values of a database, you desire only one script to find all default values.
Using below script you can find all default values and also if you require to find particular default value, you can add a filter in WHERE clause.
1 2 3 4 5 6 7 8 9 10 11 |
SELECT table_catalog ,table_schema ,table_name ,column_name ,data_type ,column_default FROM information_schema.columns WHERE table_schema = 'schema_name' AND column_default IS NOT NULL ORDER BY column_name; |