Skip to main content

PostgreSQL Daliy | PosgteSQL adninistration

List databases:

postgres-# \l
                                  List of databases
   Name    |  Owner   | Encoding |   Collate   |    Ctype    |   Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
 postgres  | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
 template0 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 template1 | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 | =c/postgres          +
           |          |          |             |             | postgres=CTc/postgres
 test      | postgres | UTF8     | en_US.UTF-8 | en_US.UTF-8 |
(4 rows)

Connect to database:
postgres-# \connect postgres
You are now connected to database "postgres" as user "postgres".

List schema:
postgres-# \dn[S+]
 information_schema | postgres | postgres=UC/postgres+|
                    |          | =U/postgres          |
 pg_catalog         | postgres | postgres=UC/postgres+| system catalog schema
                    |          | =U/postgres          |
 pg_temp_1          | postgres |                      |
 pg_toast           | postgres |                      | reserved schema for TOAST tables
 pg_toast_temp_1    | postgres |                      |
 public             | postgres | postgres=UC/postgres+| standard public schema
                    |          | =UC/postgres         |
Roles:
postgres-#  \dg[S+]
 pg_execute_server_program | Cannot login                                               | {}                                                           |
 pg_monitor                | Cannot login                                               | {pg_read_all_settings,pg_read_all_stats,pg_stat_scan_tables} |
 pg_read_all_settings      | Cannot login                                               | {}                                                           |
 pg_read_all_stats         | Cannot login                                               | {}                                                           |
 pg_read_server_files      | Cannot login                                               | {}                                                           |
 pg_signal_backend         | Cannot login                                               | {}                                                           |
 pg_stat_scan_tables       | Cannot login                                               | {}                                                           |
 pg_write_server_files     | Cannot login                                               | {}                                                           |
 postgres                  | Superuser, Create role, Create DB, Replication, Bypass RLS | {}   
 
postgres-# \connect postgres
You are now connected to database "postgres" as user "postgres".

List tables of the database postgres:
postgres-# \dt[S+]
 pg_catalog | pg_aggregate            | table | postgres | 56 kB      |
 pg_catalog | pg_am                   | table | postgres | 40 kB      |
 pg_catalog | pg_amop                 | table | postgres | 80 kB      |
 pg_catalog | pg_amproc               | table | postgres | 56 kB      |
 pg_catalog | pg_attrdef              | table | postgres | 8192 bytes |
 pg_catalog | pg_attribute            | table | postgres | 464 kB     |
 pg_catalog | pg_auth_members         | table | postgres | 40 kB      |
 pg_catalog | pg_authid               | table | postgres | 48 kB      |
 pg_catalog | pg_cast                 | table | postgres | 48 kB      |
 pg_catalog | pg_class                | table | postgres | 136 kB     |
 pg_catalog | pg_collation            | table | postgres | 424 kB     |
 pg_catalog | pg_constraint           | table | postgres | 48 kB      |
 pg_catalog | pg_conversion           | table | postgres | 56 kB      |
 pg_catalog | pg_database             | table | postgres | 48 kB      |
 pg_catalog | pg_db_role_setting      | table | postgres | 8192 bytes |
 pg_catalog | pg_default_acl          | table | postgres | 8192 bytes |
 pg_catalog | pg_depend               | table | postgres | 480 kB     |
 pg_catalog | pg_description          | table | postgres | 360 kB     |
 pg_catalog | pg_enum                 | table | postgres | 0 bytes    |
 pg_catalog | pg_event_trigger        | table | postgres | 8192 bytes |
 pg_catalog | pg_extension            | table | postgres | 48 kB      |
 pg_catalog | pg_foreign_data_wrapper | table | postgres | 8192 bytes |
 pg_catalog | pg_foreign_server       | table | postgres | 8192 bytes |
 pg_catalog | pg_foreign_table        | table | postgres | 8192 bytes |
 pg_catalog | pg_index                | table | postgres | 64 kB      |
 pg_catalog | pg_inherits             | table | postgres | 0 bytes    |
 pg_catalog | pg_init_privs           | table | postgres | 56 kB      |
 pg_catalog | pg_language             | table | postgres | 48 kB      |
 pg_catalog | pg_largeobject          | table | postgres | 0 bytes    |
 pg_catalog | pg_largeobject_metadata | table | postgres | 0 bytes    |
 pg_catalog | pg_namespace            | table | postgres | 48 kB      |
 pg_catalog | pg_opclass              | table | postgres | 48 kB      |
 pg_catalog | pg_operator             | table | postgres | 144 kB     |
 pg_catalog | pg_opfamily             | table | postgres | 48 kB      |
 pg_catalog | pg_partitioned_table    | table | postgres | 8192 bytes |
 pg_catalog | pg_pltemplate           | table | postgres | 48 kB      |
 pg_catalog | pg_policy               | table | postgres | 8192 bytes |
 pg_catalog | pg_proc                 | table | postgres | 672 kB     |
 pg_catalog | pg_publication          | table | postgres | 0 bytes    |
 pg_catalog | pg_publication_rel      | table | postgres | 0 bytes    |
 pg_catalog | pg_range                | table | postgres | 40 kB      |
 pg_catalog | pg_replication_origin   | table | postgres | 8192 bytes |
 pg_catalog | pg_rewrite              | table | postgres | 632 kB     |
 pg_catalog | pg_seclabel             | table | postgres | 8192 bytes |
 pg_catalog | pg_sequence             | table | postgres | 0 bytes    |
 pg_catalog | pg_shdepend             | table | postgres | 40 kB      |
 pg_catalog | pg_shdescription        | table | postgres | 48 kB      |
 pg_catalog | pg_shseclabel           | table | postgres | 8192 bytes |
 pg_catalog | pg_statistic            | table | postgres | 256 kB     |
 pg_catalog | pg_statistic_ext        | table | postgres | 8192 bytes |
 pg_catalog | pg_statistic_ext_data   | table | postgres | 8192 bytes |
 pg_catalog | pg_subscription         | table | postgres | 8192 bytes |
 pg_catalog | pg_subscription_rel     | table | postgres | 0 bytes    |
 pg_catalog | pg_tablespace           | table | postgres | 48 kB      |
 pg_catalog | pg_transform            | table | postgres | 0 bytes    |
 pg_catalog | pg_trigger              | table | postgres | 8192 bytes |
 pg_catalog | pg_ts_config            | table | postgres | 40 kB      |
 pg_catalog | pg_ts_config_map        | table | postgres | 56 kB      |
 pg_catalog | pg_ts_dict              | table | postgres | 48 kB      |
 pg_catalog | pg_ts_parser            | table | postgres | 40 kB      |
 pg_catalog | pg_ts_template          | table | postgres | 40 kB      |
 pg_catalog | pg_type                 | table | postgres | 120 kB     |
 pg_catalog | pg_user_mapping         | table | postgres | 8192 bytes |


Comments