10

Showing the columns and constrains of a table in PostgreSQL is done with:

\d+ <table_name>

Which lists the columns, data types and modifiers for a table.

How can I show the details and constraints of Posgresql domain?

2 Answers 2

11

To view all domains in your database, run in psql

\dD[S+] [PATTERN]      list domains

You can see the list of all psql commands with \?.

pg_constraint stores check, primary key, unique, foreign key, and exclusion constraints on tables. Column constraints are not treated specially. Every column constraint is equivalent to some table constraint. Not-null constraints are represented in the pg_attribute catalog, not here.

0
0

To get the entire list of domains in the database, you need to make an sql query:

select * from information_schema.domains 

To get a list of domains that are used in table columns to check values, you need an sql query:

select * from information_schema.column_domain_usage

The view information_schema.table_constraints contains all the constraints for the database tables.

select * from information_schema.table_constraints

The view contains all columns that use table column constraints.

select * from information_schema.constraint_column_usage

The view constraint_table_usage identifies tables that are used by some constraint

select * from information_schema.constraint_table_usage

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.