I\'m looking for a way to run a query to find the default values of the columns of a table in Postgres. For example, if I made a table with the following query:
you can just type " \d table_name" command , then It will displays some information about the table, such as the default value of a column.
--create table
skytf=> CREATE TABLE mytable (
skytf(> a integer DEFAULT 2,
skytf(> b varchar(64) DEFAULT 'I am default',
skytf(> c varchar(64) DEFAULT 'I am also default'
skytf(> );
CREATE TABLE
--show table information
skytf=> \d mytable
Table "skytf.mytable"
Column | Type | Modifiers
--------+-----------------------+------------------------------------------------
a | integer | default 2
b | character varying(64) | default 'I am default'::character varying
c | character varying(64) | default 'I am also default'::character varying