PostgreSQL Describe Table

PostgreSQL Describe Table means to get the all columns names, datatypes, size of the columns and constraints information of a table. We can get the ‘PostgreSQL Describe Table’ using \d+ table_name or describe table_name.

1) \d+ table_name
2) describe table_name

Examples

k2info=# describe emp;
Table “public.emp”
Column | Type | Modifiers
———-+—————————–+———–
empno | numeric(4,0) | not null
ename | character varying(10) |
job | character varying(9) |
mgr | numeric(4,0) |
hiredate | timestamp without time zone |
sal | numeric(7,2) |
comm | numeric(7,2) |
deptno | numeric(2,0) |
Indexes:
“pk_emp” PRIMARY KEY, btree (empno)
Foreign-key constraints:
“fk_deptno” FOREIGN KEY (deptno) REFERENCES dept(deptno)

k2info=# \d+ emp;
Table “public.emp”
Column | Type | Modifiers | Storage | Stats target | Description
———-+—————————–+———–+———-+————–+————-
empno | numeric(4,0) | not null | main | |
ename | character varying(10) | | extended | |
job | character varying(9) | | extended | |
mgr | numeric(4,0) | | main | |
hiredate | timestamp without time zone | | plain | |
sal | numeric(7,2) | | main | |
comm | numeric(7,2) | | main | |
deptno | numeric(2,0) | | main | |
Indexes:
“pk_emp” PRIMARY KEY, btree (empno)
Foreign-key constraints:
“fk_deptno” FOREIGN KEY (deptno) REFERENCES dept(deptno)

You can leave a response, or trackback from your own site.

Leave a Reply

Powered by k2schools