暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

PostgreSQL 学习笔记013 —— PostgreSQL 常用命令(3)

心有阳光 2023-01-08
514

查看数据库的启动时间

postgres=# select pg_postmaster_start_time(); pg_postmaster_start_time ------------------------------- 2023-01-02 10:39:31.176939+08 (1 row)

查看最后load配置文件时间

postgres=# select pg_conf_load_time(); pg_conf_load_time ------------------------------- 2023-01-02 10:39:30.506262+08 (1 row)

显示数据库当前时区和时间

postgres=# show timezone; TimeZone --------------- Asia/Shanghai (1 row) postgres=# select now(); now ------------------------------- 2023-01-02 20:55:31.156172+08 (1 row)

列出当前数据库下的数据表

-- \d或\d+(推荐),\d+会额外输出表的注释 postgres=# \d List of relations Schema | Name | Type | Owner --------+-------+-------+---------- public | test1 | table | postgres (1 row)

列出指定表的所有字段

-- \d 表名或\d+ 表名(推荐),\d+ 表名会额外输出字段的注释 postgres=# \d test1 Table "public.test1" Column | Type | Collation | Nullable | Default --------+---------+-----------+----------+--------- id | integer | | |

查看指定表的基本情况

postgres=# \d+ test1 Table "public.test1" Column | Type | Collation | Nullable | Default | Storage | Compression | Stats target | Description --------+---------+-----------+----------+---------+---------+-------------+--------------+------------- id | integer | | | | plain | | | Access method: heap

退出登录

postgres=# \q [postgres@192 ~]$ Ctrl + D

查看所有用户

postgres=# select * from pg_roles; rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolconnlimit | rolpassword | rolvaliduntil | rolbypassrls | rolconfig | oid ---------------------------+----------+------------+---------------+-------------+-------------+----------------+--------------+-------------+---------------+--------------+-----------+------ postgres | t | t | t | t | t | t | -1 | ******** | | t | | 10 pg_database_owner | f | t | f | f | f | f | -1 | ******** | | f | | 6171 pg_read_all_data | f | t | f | f | f | f | -1 | ******** | | f | | 6181 pg_write_all_data | f | t | f | f | f | f | -1 | ******** | | f | | 6182 pg_monitor | f | t | f | f | f | f | -1 | ******** | | f | | 3373 pg_read_all_settings | f | t | f | f | f | f | -1 | ******** | | f | | 3374 pg_read_all_stats | f | t | f | f | f | f | -1 | ******** | | f | | 3375 pg_stat_scan_tables | f | t | f | f | f | f | -1 | ******** | | f | | 3377 pg_read_server_files | f | t | f | f | f | f | -1 | ******** | | f | | 4569 pg_write_server_files | f | t | f | f | f | f | -1 | ******** | | f | | 4570 pg_execute_server_program | f | t | f | f | f | f | -1 | ******** | | f | | 4571 pg_signal_backend | f | t | f | f | f | f | -1 | ******** | | f | | 4200 (12 rows)
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

文章被以下合辑收录

评论