sql to extract the column details of a given table

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • venkat chitta
    New Member
    • Oct 2010
    • 3

    #1

    sql to extract the column details of a given table

    Hi,

    I want to extract the below column details of a given table of PostgreSQL database.

    1.column name
    2.column data type
    3.column length
    4.column precision
    5.column scale
    6.column's default value

    I can get this information from information_sch ema.columns view but i can't rely on this schema because the user can drop this schema. So i want to get the information from pg_catalog schema only.

    Thanks,
    Venkat Chitta,
    Technical Consultant,
    Infor,
    Hyderabad, India.
  • rski
    Recognized Expert Contributor
    • Dec 2006
    • 700

    #2
    information_sch ema contains views. If you check the structure of the view for example
    Code:
       \d information_schema.columns
    you will see the view definition and see tables the view is based on.

    Comment

    • vchitta

      #3
      Hi,

      I can't rely on this information_sch ema.columns view becuase this schema can be dropped by the schema owner unlike pg_catalog. So, i have to rely only on catalog tables and views.

      Thanks,
      venkat chitta.

      Comment

      Working...