About Pg_Catalog & Time zones in PostgreSQL

1. Pg System Catalogs

  • PostgreSQL store the metadata information about the database and cluster in the schema 'pg_catalog'.
  • PostgreSQL manages system catalogs by itself.
NameDescription
pg_databaseStores general database info
pg_stat_databaseContains stats information of database
pg_tablespaceContains Tablespace information
pg_operatorContains all operator information
pg_available_extensionsList all available extensions

2. Examples

C:\Users\Maxwell Pan>
C:\Users\Maxwell Pan>psql -U postgres
Password for user postgres:
psql (15.2)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=# select * from pg_database;
  oid  |  datname  | datdba | encoding | datlocprovider | datistemplate | datallowconn | datconnlimit | datfrozenxid | datminmxid | dattablespace |         datcollate         |          datctype          | daticulocale | datcollversion |                       datacl
-------+-----------+--------+----------+----------------+---------------+--------------+--------------+--------------+------------+---------------+----------------------------+----------------------------+--------------+----------------+-----------------------------------------------------
     5 | postgres  |     10 |        6 | c              | f             | t            |           -1 |          717 |          1 |          1663 | English_United States.1252 | English_United States.1252 |              |                |
     1 | template1 |     10 |        6 | c              | t             | t            |           -1 |          717 |          1 |          1663 | English_United States.1252 | English_United States.1252 |              |                | {=c/postgres,postgres=CTc/postgres}
     4 | template0 |     10 |        6 | c              | t             | f            |           -1 |          717 |          1 |          1663 | English_United States.1252 | English_United States.1252 |              |                | {=c/postgres,postgres=CTc/postgres}
 24602 | nano      |     10 |        6 | c              | f             | t            |           -1 |          717 |          1 |          1663 | English_United States.1252 | English_United States.1252 |              |                | {=Tc/postgres,postgres=CTc/postgres,ron=c/postgres}
(4 rows)


postgres=# select * from pg_stat_database;
 datid |  datname  | numbackends | xact_commit | xact_rollback | blks_read | blks_hit | tup_returned | tup_fetched | tup_inserted | tup_updated | tup_deleted | conflicts | temp_files | temp_bytes | deadlocks | checksum_failures | checksum_last_failure | blk_read_time | blk_write_time |   session_time    | active_time | idle_in_transaction_time | sessions | sessions_abandoned | sessions_fatal | sessions_killed | stats_reset
-------+-----------+-------------+-------------+---------------+-----------+----------+--------------+-------------+--------------+-------------+-------------+-----------+------------+------------+-----------+-------------------+-----------------------+---------------+----------------+-------------------+-------------+--------------------------+----------+--------------------+----------------+-----------------+-------------
     0 |           |           0 |           0 |            61 |        33 |     7231 |         2252 |        1769 |           12 |           2 |           6 |         0 |          0 |          0 |         0 |                   |                       |             0 |              0 | 44877637030378.56 |           0 |                        0 |        0 |                  0 |              0 |               0 |
     5 | postgres  |           1 |         352 |            15 |       315 |    38978 |       149811 |       14699 |            0 |           0 |           0 |         0 |          0 |          0 |         0 |                   |                       |             0 |              0 |       4107592.457 |    3152.605 |                        0 |       23 |                  0 |              0 |               0 |
     1 | template1 |           0 |           0 |             0 |         0 |        0 |            0 |           0 |            0 |           0 |           0 |         0 |          0 |          0 |         0 |                   |                       |             0 |              0 |                 0 |           0 |                        0 |        0 |                  0 |              0 |               0 |
     4 | template0 |           0 |           0 |             0 |         0 |        0 |            0 |           0 |            0 |           0 |           0 |         0 |          0 |          0 |         0 |                   |                       |             0 |              0 |                 0 |           0 |                        0 |        0 |                  0 |              0 |               0 |
 24602 | nano      |           0 |         333 |             8 |       218 |    15965 |       129131 |        4634 |           58 |           4 |          28 |         0 |          0 |          0 |         0 |                   |                       |             0 |              0 |       1814961.106 |    2322.586 |                        0 |       15 |                  0 |              0 |               0 |
(5 rows)


postgres=# select * from pg_tablespace;
 oid  |  spcname   | spcowner | spcacl | spcoptions
------+------------+----------+--------+------------
 1663 | pg_default |       10 |        |
 1664 | pg_global  |       10 |        |
(2 rows)


postgres=# select * from pg_operator;
 oid  | oprname | oprnamespace | oprowner | oprkind | oprcanmerge | oprcanhash | oprleft | oprright | oprresult | oprcom | oprnegate |              oprcode               |    oprrest    |     oprjoin
------+---------+--------------+----------+---------+-------------+------------+---------+----------+-----------+--------+-----------+------------------------------------+---------------+------------------
   15 | =       |           11 |       10 | b       | t           | t          |      23 |       20 |        16 |    416 |        36 | int48eq                            | eqsel         | eqjoinsel
   36 | <>      |           11 |       10 | b       | f           | f          |      23 |       20 |        16 |    417 |        15 | int48ne                            | neqsel        | neqjoinsel
   37 | <       |           11 |       10 | b       | f           | f          |      23 |       20 |        16 |    419 |        82 | int48lt                            | scalarltsel   | scalarltjoinsel
   76 | >       |           11 |       10 | b       | f           | f          |      23 |       20 |        16 |    418 |        80 | int48gt                            | scalargtsel   | scalargtjoinsel
   80 | <=      |           11 |       10 | b       | f           | f          |      23 |       20 |        16 |    430 |        76 | int48le                            | scalarlesel   | scalarlejoinsel
   82 | >=      |           11 |       10 | b       | f           | f          |      23 |       20 |        16 |    420 |        37 | int48ge                            | scalargesel   | scalargejoinsel
   58 | <       |           11 |       10 | b       | f           | f          |      16 |       16 |        16 |     59 |      1695 | boollt                             | scalarltsel   | scalarltjoinsel
   59 | >       |           11 |       10 | b       | f           | f          |      16 |       16 |        16 |     58 |      1694 | boolgt                             | scalargtsel   | scalargtjoinsel
   85 | <>      |           11 |       10 | b       | f           | f          |      16 |       16 |        16 |     85 |        91 | boolne                             | neqsel        | neqjoinsel
   91 | =       |           11 |       10 | b       | t           | t          |      16 |       16 |        16 |     91 |        85 | booleq                             | eqsel         | eqjoinsel
 1694 | <=      |           11 |       10 | b       | f           | f          |      16 |       16 |        16 |   1695 |        59 | boolle                             | scalarlesel   | scalarlejoinsel
 1695 | >=      |           11 |       10 | b       | f           | f          |      16 |       16 |        16 |   1694 |        58 | boolge                             | scalargesel   | scalargejoinsel
   92 | =       |           11 |       10 | b       | t           | t          |      18 |       18 |        16 |     92 |       630 | chareq                             | eqsel         | eqjoinsel
   93 | =       |           11 |       10 | b       | t           | t          |      19 |       19 |        16 |     93 |       643 | nameeq                             | eqsel         | eqjoinsel
   94 | =       |           11 |       10 | b       | t           | t          |      21 |       21 |        16 |     94 |       519 | int2eq                             | eqsel         | eqjoinsel
   95 | <       |           11 |       10 | b       | f           | f          |      21 |       21 |        16 |    520 |       524 | int2lt                             | scalarltsel   | scalarltjoinsel
   96 | =       |           11 |       10 | b       | t           | t          |      23 |       23 |        16 |     96 |       518 | int4eq                             | eqsel         | eqjoinsel
   97 | <       |           11 |       10 | b       | f           | f          |      23 |       23 |        16 |    521 |       525 | int4lt                             | scalarltsel   | scalarltjoinsel
   98 | =       |           11 |       10 | b       | t           | t          |      25 |       25 |        16 |     98 |       531 | texteq                             | eqsel         | eqjoinsel
 3877 | ^@      |           11 |       10 | b       | f           | f          |      25 |       25 |        16 |      0 |         0 | starts_with                        | prefixsel     | prefixjoinsel
  254 | =       |           11 |       10 | b       | t           | t          |      19 |       25 |        16 |    260 |       259 | nameeqtext                         | eqsel         | eqjoinsel
  255 | <       |           11 |       10 | b       | f           | f          |      19 |       25 |        16 |    264 |       257 | namelttext                         | scalarltsel   | scalarltjoinsel
  256 | <=      |           11 |       10 | b       | f           | f          |      19 |       25 |        16 |    263 |       258 | nameletext                         | scalarlesel   | scalarlejoinsel
  257 | >=      |           11 |       10 | b       | f           | f          |      19 |       25 |        16 |    262 |       255 | namegetext                         | scalargesel   | scalargejoinsel
  258 | >       |           11 |       10 | b       | f           | f          |      19 |       25 |        16 |    261 |       256 | namegttext                         | scalargtsel   | scalargtjoinsel
  259 | <>      |           11 |       10 | b       | f           | f          |      19 |       25 |        16 |    265 |       254 | namenetext                         | neqsel        | neqjoinsel
  260 | =       |           11 |       10 | b       | t           | t          |      25 |       19 |        16 |    254 |       265 | texteqname                         | eqsel         | eqjoinsel
  261 | <       |           11 |       10 | b       | f           | f          |      25 |       19 |        16 |    258 |       263 | textltname                         | scalarltsel   | scalarltjoinsel
  262 | <=      |           11 |       10 | b       | f           | f          |      25 |       19 |        16 |    257 |       264 | textlename                         | scalarlesel   | scalarlejoinsel
  263 | >=      |           11 |       10 | b       | f           | f          |      25 |       19 |        16 |    256 |       261 | textgename                         | scalargesel   | scalargejoinsel
  264 | >       |           11 |       10 | b       | f           | f          |      25 |       19 |        16 |    255 |       262 | textgtname                         | scalargtsel   | scalargtjoinsel
  265 | <>      |           11 |       10 | b       | f           | f          |      25 |       19 |        16 |    259 |       260 | textnename                         | neqsel        | neqjoinsel
  349 | ||      |           11 |       10 | b       | f           | f          |    5078 |     5077 |      5078 |      0 |         0 | array_append                       | -             | -
  374 | ||      |           11 |       10 | b       | f           | f          |    5077 |     5078 |      5078 |      0 |         0 | array_prepend                      | -             | -
  375 | ||      |           11 |       10 | b       | f           | f          |    5078 |     5078 |      5078 |      0 |         0 | array_cat                          | -             | -
  352 | =       |           11 |       10 | b       | f           | t          |      28 |       28 |        16 |    352 |      3315 | xideq                              | eqsel         | eqjoinsel
  353 | =       |           11 |       10 | b       | f           | f          |      28 |       23 |        16 |      0 |      3316 | xideqint4                          | eqsel         | eqjoinsel
 3315 | <>      |           11 |       10 | b       | f           | f          |      28 |       28 |        16 |   3315 |       352 | xidneq                             | neqsel        | neqjoinsel
 3316 | <>      |           11 |       10 | b       | f           | f          |      28 |       23 |        16 |      0 |       353 | xidneqint4                         | neqsel        | neqjoinsel
 5068 | =       |           11 |       10 | b       | t           | t          |    5069 |     5069 |        16 |   5068 |      5072 | xid8eq                             | eqsel         | eqjoinsel
 5072 | <>      |           11 |       10 | b       | f           | f          |    5069 |     5069 |        16 |   5072 |      5068 | xid8ne                             | neqsel        | neqjoinsel
 5073 | <       |           11 |       10 | b       | f           | f          |    5069 |     5069 |        16 |   5074 |      5076 | xid8lt                             | scalarltsel   | scalarltjoinsel
 5074 | >       |           11 |       10 | b       | f           | f          |    5069 |     5069 |        16 |   5073 |      5075 | xid8gt                             | scalargtsel   | scalargtjoinsel
 5075 | <=      |           11 |       10 | b       | f           | f          |    5069 |     5069 |        16 |   5076 |      5074 | xid8le                             | scalarlesel   | scalarlejoinsel
 5076 | >=      |           11 |       10 | b       | f           | f          |    5069 |     5069 |        16 |   5075 |      5073 | xid8ge                             | scalargesel   | scalargejoinsel
  385 | =       |           11 |       10 | b       | f           | t          |      29 |       29 |        16 |    385 |         0 | cideq                              | eqsel         | eqjoinsel
  387 | =       |           11 |       10 | b       | t           | t          |      27 |       27 |        16 |    387 |       402 | tideq                              | eqsel         | eqjoinsel
  402 | <>      |           11 |       10 | b       | f           | f          |      27 |       27 |        16 |    402 |       387 | tidne                              | neqsel        | neqjoinsel
 2799 | <       |           11 |       10 | b       | f           | f          |      27 |       27 |        16 |   2800 |      2802 | tidlt                              | scalarltsel   | scalarltjoinsel
 2800 | >       |           11 |       10 | b       | f           | f          |      27 |       27 |        16 |   2799 |      2801 | tidgt                              | scalargtsel   | scalargtjoinsel
 2801 | <=      |           11 |       10 | b       | f           | f          |      27 |       27 |        16 |   2802 |      2800 | tidle                              | scalarlesel   | scalarlejoinsel
 2802 | >=      |           11 |       10 | b       | f           | f          |      27 |       27 |        16 |   2801 |      2799 | tidge                              | scalargesel   | scalargejoinsel
  410 | =       |           11 |       10 | b       | t           | t          |      20 |       20 |        16 |    410 |       411 | int8eq                             | eqsel         | eqjoinsel
  411 | <>      |           11 |       10 | b       | f           | f          |      20 |       20 |        16 |    411 |       410 | int8ne                             | neqsel        | neqjoinsel
  412 | <       |           11 |       10 | b       | f           | f          |      20 |       20 |        16 |    413 |       415 | int8lt                             | scalarltsel   | scalarltjoinsel
  413 | >       |           11 |       10 | b       | f           | f          |      20 |       20 |        16 |    412 |       414 | int8gt                             | scalargtsel   | scalargtjoinsel
  414 | <=      |           11 |       10 | b       | f           | f          |      20 |       20 |        16 |    415 |       413 | int8le                             | scalarlesel   | scalarlejoinsel
  415 | >=      |           11 |       10 | b       | f           | f          |      20 |       20 |        16 |    414 |       412 | int8ge                             | scalargesel   | scalargejoinsel
  416 | =       |           11 |       10 | b       | t           | t          |      20 |       23 |        16 |     15 |       417 | int84eq                            | eqsel         | eqjoinsel
  417 | <>      |           11 |       10 | b       | f           | f          |      20 |       23 |        16 |     36 |       416 | int84ne                            | neqsel        | neqjoinsel
  418 | <       |           11 |       10 | b       | f           | f          |      20 |       23 |        16 |     76 |       430 | int84lt                            | scalarltsel   | scalarltjoinsel
  419 | >       |           11 |       10 | b       | f           | f          |      20 |       23 |        16 |     37 |       420 | int84gt                            | scalargtsel   | scalargtjoinsel
  420 | <=      |           11 |       10 | b       | f           | f          |      20 |       23 |        16 |     82 |       419 | int84le                            | scalarlesel   | scalarlejoinsel
^CCancel request sent
postgres=#
C:\Users\Maxwell Pan>pg_ctl status
pg_ctl: no server running

C:\Users\Maxwell Pan>pg_ctl start
waiting for server to start....2023-04-25 11:14:13.053 CST [18480] LOG:  redirecting log output to logging collector process
2023-04-25 11:14:13.053 CST [18480] HINT:  Future log output will appear in directory "log".
 done
server started

C:\Users\Maxwell Pan>psql -U postgres
Password for user postgres:
psql (15.2)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=#
postgres=# select * from pg_shadow;
 usename  | usesysid | usecreatedb | usesuper | userepl | usebypassrls |                                                                passwd                                                                 | valuntil | useconfig
----------+----------+-------------+----------+---------+--------------+---------------------------------------------------------------------------------------------------------------------------------------+----------+-----------
 postgres |       10 | t           | t        | t       | t            | SCRAM-SHA-256$4096:BsDkIbrb3e4lL2bBCKcIbQ==$yWewHz+ULWqS9xQ5W3TqomcYotcKBAD336pvH49UyD4=:pyeJzwmbkoZm+OPQL00FjIAJBjIfDz3ezDIyxKf/rU4= |          |
 scott    |    24582 | f           | t        | f       | f            | SCRAM-SHA-256$4096:64U6TqdG6RXDfdexWkhcpg==$ZSPC0F/0fQ5RSNv3W0b4JHIB5TlzbJyiBx6EJyiWkkk=:xJBm0R3A/4QR8jHuxL+IUjOoeYer/XI5D7n56mA1VXY= |          |
 sam      |    24601 | t           | f        | f       | f            | SCRAM-SHA-256$4096:7AmjizcS4uCraRXSVGjFsg==$9fPB5r0mitAcovh11q+VKYmSTo9wDJRuSkjw4jocxKM=:Xm+mODf5X872X77IcfOrihFh2ozVnTptnNO+bpaVnnM= |          |
 ronk     |    32772 | f           | f        | f       | f            | SCRAM-SHA-256$4096:jaHP7s41pulrAbEcKfaUdA==$/Ex3pDDQu7Vc9kqN0YOiUO/ZMnHXnct+3ap3MXMz9ng=:Cf7w7JHZ1YbmV0NEnZzz5NK16Lj5FU/5s62FHMZSqxk= |          |
 ron      |    24599 | f           | f        | f       | f            |                                                                                                                                       |          |
(5 rows)


postgres=# \du
                                   List of roles
 Role name |                         Attributes                         | Member of
-----------+------------------------------------------------------------+-----------
 postgres  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}
 ron       |                                                            | {}
 ronk      |                                                            | {}
 sam       | Create DB                                                  | {}
 scott     | Superuser                                                  | {}


postgres=# select * from pg_timezone_names;
               name               | abbrev | utc_offset | is_dst
----------------------------------+--------+------------+--------
 Africa/Abidjan                   | GMT    | 00:00:00   | f
 Africa/Accra                     | GMT    | 00:00:00   | f
 Africa/Addis_Ababa               | EAT    | 03:00:00   | f
 Africa/Algiers                   | CET    | 01:00:00   | f
 Africa/Asmara                    | EAT    | 03:00:00   | f
 Africa/Asmera                    | EAT    | 03:00:00   | f
 Africa/Bamako                    | GMT    | 00:00:00   | f
 Africa/Bangui                    | WAT    | 01:00:00   | f
 Africa/Banjul                    | GMT    | 00:00:00   | f
 Africa/Bissau                    | GMT    | 00:00:00   | f
 Africa/Blantyre                  | CAT    | 02:00:00   | f
 Africa/Brazzaville               | WAT    | 01:00:00   | f
 Africa/Bujumbura                 | CAT    | 02:00:00   | f
 Africa/Cairo                     | EET    | 02:00:00   | f
 Africa/Casablanca                | +00    | 00:00:00   | t
 Africa/Ceuta                     | CEST   | 02:00:00   | t
 Africa/Conakry                   | GMT    | 00:00:00   | f
 Africa/Dakar                     | GMT    | 00:00:00   | f
 Africa/Dar_es_Salaam             | EAT    | 03:00:00   | f
 Africa/Djibouti                  | EAT    | 03:00:00   | f
 Africa/Douala                    | WAT    | 01:00:00   | f
 Africa/El_Aaiun                  | +00    | 00:00:00   | t
 Africa/Freetown                  | GMT    | 00:00:00   | f
 Africa/Gaborone                  | CAT    | 02:00:00   | f
 Africa/Harare                    | CAT    | 02:00:00   | f
 Africa/Johannesburg              | SAST   | 02:00:00   | f
 Africa/Juba                      | CAT    | 02:00:00   | f
 Africa/Kampala                   | EAT    | 03:00:00   | f
 Africa/Khartoum                  | CAT    | 02:00:00   | f
 Africa/Kigali                    | CAT    | 02:00:00   | f
 Africa/Kinshasa                  | WAT    | 01:00:00   | f
 Africa/Lagos                     | WAT    | 01:00:00   | f
 Africa/Libreville                | WAT    | 01:00:00   | f
 Africa/Lome                      | GMT    | 00:00:00   | f
 Africa/Luanda                    | WAT    | 01:00:00   | f
 Africa/Lubumbashi                | CAT    | 02:00:00   | f
 Africa/Lusaka                    | CAT    | 02:00:00   | f
 Africa/Malabo                    | WAT    | 01:00:00   | f
 Africa/Maputo                    | CAT    | 02:00:00   | f
 Africa/Maseru                    | SAST   | 02:00:00   | f
 Africa/Mbabane                   | SAST   | 02:00:00   | f
 Africa/Mogadishu                 | EAT    | 03:00:00   | f
 Africa/Monrovia                  | GMT    | 00:00:00   | f
 Africa/Nairobi                   | EAT    | 03:00:00   | f
 Africa/Ndjamena                  | WAT    | 01:00:00   | f
 Africa/Niamey                    | WAT    | 01:00:00   | f
 Africa/Nouakchott                | GMT    | 00:00:00   | f
 Africa/Ouagadougou               | GMT    | 00:00:00   | f
 Africa/Porto-Novo                | WAT    | 01:00:00   | f
 Africa/Sao_Tome                  | GMT    | 00:00:00   | f
 Africa/Timbuktu                  | GMT    | 00:00:00   | f
 Africa/Tripoli                   | EET    | 02:00:00   | f
 Africa/Tunis                     | CET    | 01:00:00   | f
 Africa/Windhoek                  | CAT    | 02:00:00   | f
 America/Adak                     | HDT    | -09:00:00  | t
 America/Anchorage                | AKDT   | -08:00:00  | t
 America/Anguilla                 | AST    | -04:00:00  | f
 America/Antigua                  | AST    | -04:00:00  | f
 America/Araguaina                | -03    | -03:00:00  | f
 America/Argentina/Buenos_Aires   | -03    | -03:00:00  | f
 America/Argentina/Catamarca      | -03    | -03:00:00  | f
 America/Argentina/ComodRivadavia | -03    | -03:00:00  | f
 America/Argentina/Cordoba        | -03    | -03:00:00  | f
^CCancel request sent
postgres=#
postgres=#
C:\Users\Maxwell Pan>psql -U postgres
Password for user postgres:
psql (15.2)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=# select * from pg_tables;
     schemaname     |        tablename         | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity
--------------------+--------------------------+------------+------------+------------+----------+-------------+-------------
 pg_catalog         | pg_statistic             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_type                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_foreign_table         | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_authid                | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_statistic_ext_data    | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_user_mapping          | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_subscription          | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_attribute             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_proc                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_class                 | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_attrdef               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_constraint            | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_inherits              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_index                 | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_operator              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_opfamily              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_opclass               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_am                    | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_amop                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_amproc                | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_language              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_largeobject_metadata  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_aggregate             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_statistic_ext         | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_rewrite               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_trigger               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_event_trigger         | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_description           | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_cast                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_enum                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_namespace             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_conversion            | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_depend                | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_database              | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_db_role_setting       | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_tablespace            | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_auth_members          | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_shdepend              | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_shdescription         | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_ts_config             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_ts_config_map         | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_ts_dict               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_ts_parser             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_ts_template           | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_extension             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_foreign_data_wrapper  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_foreign_server        | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_policy                | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_replication_origin    | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_default_acl           | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_init_privs            | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_seclabel              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_shseclabel            | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_collation             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_parameter_acl         | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_partitioned_table     | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_range                 | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_transform             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_sequence              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_publication           | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_publication_namespace | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_publication_rel       | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_subscription_rel      | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_largeobject           | postgres   |            | t          | f        | f           | f
 information_schema | sql_features             | postgres   |            | f          | f        | f           | f
 information_schema | sql_implementation_info  | postgres   |            | f          | f        | f           | f
 information_schema | sql_parts                | postgres   |            | f          | f        | f           | f
 information_schema | sql_sizing               | postgres   |            | f          | f        | f           | f
(68 rows)


postgres=#
C:\Users\Maxwell Pan>psql -U postgres
Password for user postgres:
psql (15.2)
WARNING: Console code page (437) differs from Windows code page (1252)
         8-bit characters might not work correctly. See psql reference
         page "Notes for Windows users" for details.
Type "help" for help.

postgres=# select * from pg_tables;
     schemaname     |        tablename         | tableowner | tablespace | hasindexes | hasrules | hastriggers | rowsecurity
--------------------+--------------------------+------------+------------+------------+----------+-------------+-------------
 pg_catalog         | pg_statistic             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_type                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_foreign_table         | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_authid                | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_statistic_ext_data    | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_user_mapping          | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_subscription          | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_attribute             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_proc                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_class                 | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_attrdef               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_constraint            | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_inherits              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_index                 | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_operator              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_opfamily              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_opclass               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_am                    | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_amop                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_amproc                | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_language              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_largeobject_metadata  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_aggregate             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_statistic_ext         | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_rewrite               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_trigger               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_event_trigger         | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_description           | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_cast                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_enum                  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_namespace             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_conversion            | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_depend                | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_database              | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_db_role_setting       | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_tablespace            | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_auth_members          | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_shdepend              | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_shdescription         | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_ts_config             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_ts_config_map         | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_ts_dict               | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_ts_parser             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_ts_template           | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_extension             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_foreign_data_wrapper  | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_foreign_server        | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_policy                | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_replication_origin    | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_default_acl           | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_init_privs            | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_seclabel              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_shseclabel            | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_collation             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_parameter_acl         | postgres   | pg_global  | t          | f        | f           | f
 pg_catalog         | pg_partitioned_table     | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_range                 | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_transform             | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_sequence              | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_publication           | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_publication_namespace | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_publication_rel       | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_subscription_rel      | postgres   |            | t          | f        | f           | f
 pg_catalog         | pg_largeobject           | postgres   |            | t          | f        | f           | f
 information_schema | sql_features             | postgres   |            | f          | f        | f           | f
 information_schema | sql_implementation_info  | postgres   |            | f          | f        | f           | f
 information_schema | sql_parts                | postgres   |            | f          | f        | f           | f
 information_schema | sql_sizing               | postgres   |            | f          | f        | f           | f
(68 rows)


postgres=#

3. Working with Time Zones

postgres=#
postgres=# select current_schema();
 current_schema
----------------
 public
(1 row)


postgres=# select current_user;
 current_user
--------------
 postgres
(1 row)


postgres=# select current_database();
 current_database
------------------
 postgres
(1 row)


postgres=# select current_setting('max_parallel_workers');
 current_setting
-----------------
 8
(1 row)


postgres=# select current_setting('max_connections');
 current_setting
-----------------
 100
(1 row)


postgres=# select pg_postmaster_start_time();
   pg_postmaster_start_time
-------------------------------
 2023-04-25 11:21:56.904658+08
(1 row)


postgres=# select now() as current;
            current
-------------------------------
 2023-04-25 11:28:46.765431+08
(1 row)


postgres=# select (now() + interval '1 hour') as an_hour_later;
        an_hour_later
------------------------------
 2023-04-25 12:29:24.39778+08
(1 row)


postgres=# select (now() + interval '1 day') a_day_later;
         a_day_later
------------------------------
 2023-04-26 11:30:02.79809+08
(1 row)


postgres=# select now() - interval '2 hours 30 minutes' as deduct_time;
          deduct_time
-------------------------------
 2023-04-25 09:00:43.917592+08
(1 row)


postgres=#
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值