Query below summarizes default constraints in a database listing all distinct default value definitions for columns with the number of their occurrence.
Query
select column_default,
count(distinct table_id) as tables,
count(column_name) as columns
from v_catalog.columns
group by column_default
order by count(column_name) desc;
Columns
- column_default - definition of default constraint (formula)
- [NULL] for identity columns
- blank column default means default constaint was not defined
- tables - number of tables with this constraint (or number of tables with columns with no constraints for blank row)
- columns - number of columns with this particular constraint (or no constraint for blank row)
Rows
- One row represents one unique definition of default value
- Scope of rows: all distinct definitions of default column values in a database
- Ordered by the number of occurrences from the most popular