Posts for: #TIL

Psql Gdesc

Came across gdesc psql command.

Can come handy if one needs is to check what column datatypes they use/returned:

db=> select * from companies `\gdesc`
   Column    |           Type
-------------+--------------------------
 id          | uuid
 name        | character varying(255)
 external_id | character varying(255)
 customer_id | uuid
 provider_id | uuid
 redirect    | text
 created_at  | timestamp with time zone
 updated_at  | timestamp with time zone
[Read more]

Postgres Drop Cols or Not

TIL, dropping a column from a table in postgres doesn’t delete it real.

instead it stays on the disk and files and is ignored and taken into account by the postgres parsers.

When a column is dropped attisdropped is set in catalog (which stores information about cols)

There is exactly 1 pg_attributes row for every column in every db.

Which means this column has been dropped and is no longer valid. A dropped column is still physically present in the table, but is ignored by the parser and so cannot be accessed via SQL.

[Read more]