How to list custom types using Postgres information_schema

后端 未结 7 1498
遥遥无期
遥遥无期 2020-12-28 12:40

I am trying to find the equivalent SQL of \\dT using the information_schema and can\'t seem to find anything. Does such a thing exist?

Example: If I add the followi

7条回答
  •  梦谈多话
    2020-12-28 13:06

    List all db types:

    test=# \dT
                 List of data types
     Schema |        Name         | Description
    --------+---------------------+-------------
     public | gender              |
     public | status              |
    

    List all db types with additional information like values:

    test=# \dT+
                                                       List of data types
     Schema |        Name         |    Internal name    | Size |     Elements      | Owner | Access privileges | Description
    --------+---------------------+---------------------+------+-------------------+-------+-------------------+-------------
     public | gender              | gender              | 4    | male             +| Vadim |                   |
            |                     |                     |      | female            |       |                   |
     public | status              | status              | 4    | processing       +| Vadim |                   |
            |                     |                     |      | passed           +|       |                   |
            |                     |                     |      | failed            |       |                   |
    

    Get certain type with additional information:

    leps=# \dT+ gender
                                                List of data types
     Schema |  Name  | Internal name | Size | Elements | Owner | Access privileges | Description
    --------+------------+---------------+------+-------------------+-------+-------------------+-------------
     public | gender | gender        | 4    | male    +| Vadim |                   |
            |        |               |      | female  +|       |                   |
    

提交回复
热议问题