1. 程式人生 > >PostgreSQL列舉所有的表空間及schema及角色

PostgreSQL列舉所有的表空間及schema及角色

highgo=# \db              --列舉出所有的表空間
      List of tablespaces
    Name    | Owner  | Location 
------------+--------+----------
 pg_default | highgo | 
 pg_global  | highgo | 
(2 rows)


highgo=# \dn                      ----列舉出所有的schema
     List of schemas
      Name      | Owner  
----------------+--------
 hgdb_catalog   | highgo
 oracle_catalog | highgo
 public         | highgo
(3 rows)


highgo=# \du                          列舉出所有的角色或使用者
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 highgo    | Superuser, Create role, Create DB, Replication | {}
 
 
 
highgo=# create role aaaa;
CREATE ROLE
highgo=# \dn
     List of schemas
      Name      | Owner  
----------------+--------
 hgdb_catalog   | highgo
 oracle_catalog | highgo
 public         | highgo
(3 rows)


highgo=# \du
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 aaaa      | Cannot login                                   | {}
 highgo    | Superuser, Create role, Create DB, Replication | {}


highgo=# create schema aaa;
CREATE SCHEMA
highgo=# 
highgo=# \du
                             List of roles
 Role name |                   Attributes                   | Member of 
-----------+------------------------------------------------+-----------
 aaaa      | Cannot login                                   | {}
 highgo    | Superuser, Create role, Create DB, Replication | {}


highgo=# \dn
     List of schemas
      Name      | Owner  
----------------+--------
 aaa            | highgo
 hgdb_catalog   | highgo
 oracle_catalog | highgo
 public         | highgo
(4 rows)