0
点赞
收藏
分享

微信扫一扫

PGSQL17客户端支持大量SHOW命令


功能

MYSQL风格

PG风格

列出所有数据库

show databases

\l

切换数据库

use database_name

\c database_name

当前数据库的所有表

show tables

\d

查看表结构

desc table_name

\d table_name

显示所有索引

show indexs

\di

显示所有序列

show sequences

\ds

显示所有视图

show views

\dv

显示所有函数

show functions

\df

显示所有的表空间

show tablespaces

\db

显示所有schema

show schemas

\dn

显示所有用户

show users

\du

显示表的权限分配

show privileges

\dp




下面两个功能未实现

有BUG别用


显示所有触发器

show trigs

显示某函数定义

show  func name

\sf

[shark@sharkdb=>bin]$./pgsql -d testdb
pgsql (17.1)
Type "help" for help.
SHARKSQL> select version();
+--------------------------------------------------------------------------+
|                                 version                                  |
+--------------------------------------------------------------------------+
| SharkDB 17.1 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 5.5.0, 64-bit |
+--------------------------------------------------------------------------+
(1 row)
Time: 22.574 ms
SHARKSQL>



显示所有的数据库

SHARKSQL> show databases
                                                  List of databases
+-----------+-------+----------+-----------------+------------+------------+--------+-----------+-------------------+
|   Name    | Owner | Encoding | Locale Provider |  Collate   |   Ctype    | Locale | ICU Rules | Access privileges |
+-----------+-------+----------+-----------------+------------+------------+--------+-----------+-------------------+
| sharkdb   | shark | UTF8     | libc            | zh_CN.utf8 | zh_CN.utf8 |        |           |                   |
| template0 | shark | UTF8     | libc            | zh_CN.utf8 | zh_CN.utf8 |        |           | =c/shark         +|
|           |       |          |                 |            |            |        |           | shark=CTc/shark   |
| template1 | shark | UTF8     | libc            | zh_CN.utf8 | zh_CN.utf8 |        |           | =c/shark         +|
|           |       |          |                 |            |            |        |           | shark=CTc/shark   |
| testdb    | shark | UTF8     | libc            | zh_CN.utf8 | zh_CN.utf8 |        |           | =Tc/shark        +|
|           |       |          |                 |            |            |        |           | shark=CTc/shark  +|
|           |       |          |                 |            |            |        |           | b_jar=c/shark     |
+-----------+-------+----------+-----------------+------------+------------+--------+-----------+-------------------+
(4 rows)

显示所有表

SHARKSQL> show tables
                List of relations
+--------+--------------------+----------+-------+
| Schema |        Name        |   Type   | Owner |
+--------+--------------------+----------+-------+
| public | departments        | table    | shark |
| public | departments_id_seq | sequence | shark |
| public | employees          | table    | shark |
| public | employees_id_seq   | sequence | shark |
| public | v_depemp           | view     | shark |
+--------+--------------------+----------+-------+
(5 rows)

显示某个表的结构

SHARKSQL> desc departments
                                         Table "public.departments"
+-----------------+------------------------+-----------+----------+-----------------------------------------+
|     Column      |          Type          | Collation | Nullable |                 Default                 |
+-----------------+------------------------+-----------+----------+-----------------------------------------+
| id              | integer                |           | not null | nextval('departments_id_seq'::regclass) |
| department_name | character varying(100) |           | not null |                                         |
+-----------------+------------------------+-----------+----------+-----------------------------------------+
Indexes:
    "departments_pkey" PRIMARY KEY, btree (id)
Referenced by:
    TABLE "employees" CONSTRAINT "employees_department_id_fkey" FOREIGN KEY (department_id) REFERENCES departments(id)

显示所有索引

SHARKSQL> show indexs
                     List of relations
+--------+------------------+-------+-------+-------------+
| Schema |       Name       | Type  | Owner |    Table    |
+--------+------------------+-------+-------+-------------+
| public | departments_pkey | index | shark | departments |
| public | employees_pkey   | index | shark | employees   |
+--------+------------------+-------+-------+-------------+
(2 rows)

显示所有序列

SHARKSQL> show sequences
                List of relations
+--------+--------------------+----------+-------+
| Schema |        Name        |   Type   | Owner |
+--------+--------------------+----------+-------+
| public | departments_id_seq | sequence | shark |
| public | employees_id_seq   | sequence | shark |
+--------+--------------------+----------+-------+
(2 rows)

显示所有视图

SHARKSQL> show views
         List of relations
+--------+----------+------+-------+
| Schema |   Name   | Type | Owner |
+--------+----------+------+-------+
| public | v_depemp | view | shark |
+--------+----------+------+-------+
(1 row)

显示所有函数

SHARKSQL> show functions
                            List of functions
+--------+-------------+------------------+----------------------+------+
| Schema |    Name     | Result data type | Argument data types  | Type |
+--------+-------------+------------------+----------------------+------+
| public | add_numbers | integer          | a integer, b integer | func |
+--------+-------------+------------------+----------------------+------+
(1 row)

显示所有的表空间

SHARKSQL> show tablespaces
       List of tablespaces
+------------+-------+----------+
|    Name    | Owner | Location |
+------------+-------+----------+
| pg_default | shark |          |
| pg_global  | shark |          |
+------------+-------+----------+
(2 rows)

显示所有schema

SHARKSQL> show schemas
       List of schemas
+--------+-------------------+
|  Name  |       Owner       |
+--------+-------------------+
| public | pg_database_owner |
+--------+-------------------+
(1 row)

显示所有用户

SHARKSQL> show users
                              List of roles
+-----------+------------------------------------------------------------+
| Role name |                         Attributes                         |
+-----------+------------------------------------------------------------+
| b_jar     |                                                            |
| shark     | Superuser, Create role, Create DB, Replication, Bypass RLS |
+-----------+------------------------------------------------------------+

显示所有权限

SHARKSQL> show privileges
                                      Access privileges
+--------+--------------------+----------+-------------------+-------------------+----------+
| Schema |        Name        |   Type   | Access privileges | Column privileges | Policies |
+--------+--------------------+----------+-------------------+-------------------+----------+
| public | departments        | table    |                   |                   |          |
| public | departments_id_seq | sequence |                   |                   |          |
| public | employees          | table    |                   |                   |          |
| public | employees_id_seq   | sequence |                   |                   |          |
| public | v_depemp           | view     |                   |                   |          |
+--------+--------------------+----------+-------------------+-------------------+----------+
(5 rows)

下载地址: 公众号的末尾

通过网盘分享的文件:pgsql17

下载

举报

相关推荐

0 条评论