describe table in postgres code example

Example 1: describe table postgres

postgres=# \d schema.tablename;

Example 2: postgre describe table

SELECT 
   table_name, 
   column_name, 
   data_type 
FROM 
   information_schema.columns
WHERE 
   table_name = 'city';

Example 3: show details of table postgres

postgres=# \d tablename;

Example 4: select from describe sql

SELECT COLUMN_NAME AS `Field`, COLUMN_TYPE AS `Type`, IS_NULLABLE AS `NULL`, 
       COLUMN_KEY AS `Key`, COLUMN_DEFAULT AS `Default`, EXTRA AS `Extra`
FROM information_schema.COLUMNS  
WHERE TABLE_SCHEMA = 'schemaName' AND TABLE_NAME = 'table1';

Tags:

Misc Example