GreatSQL社区

搜索

DB架构师:曾凡坤

PGSQL17客户端支持大量SHOW命令

DB架构师:曾凡坤 已有 128 次阅读2024-12-21 07:53 |个人分类:PG|系统分类:运维实战

功能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
显示所有schemashow schemas\dn
显示所有用户show users\du
显示表的权限分配show privileges\dp
下面两个功能未实现有BUG别用
显示所有触发器show trigs
显示某函数定义show func name\sf
  • [shark@sharkdb=>bin]$./pgsql -d testdbpgsql (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 msSHARKSQL> 

    显示所有的数据库

  • 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)



    这个BUG耗费我很长时间,尚未解决

  • SHARKSQL> show  func check_agepi*** Error in `./pgsql': double free or corruption (fasttop): 0x0000000000d969a0 ***======= Backtrace: =========/lib64/libc.so.6(+0x81329)[0x7f203a410329]./pgsql[0x424eb6]./pgsql[0x42eec4]/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f203a3b1555]./pgsql[0x404f49]======= Memory map: ========00400000-004b2000 r-xp 00000000 fd:03 69046515                           /Program/sharkdb17/db_soft/bin/pgsql006b2000-006b3000 r--p 000b2000 fd:03 69046515                           /Program/sharkdb17/db_soft/bin/pgsql
    


    通过网盘分享的文件:pgsql17


    评论 (0 个评论)

    facelist

    您需要登录后才可以评论 登录 | 立即注册

    合作电话:010-64087828

    社区邮箱:greatsql@greatdb.com

    社区公众号
    社区小助手
    QQ群
    GMT+8, 2025-3-14 03:30 , Processed in 0.018648 second(s), 10 queries , Redis On.
    返回顶部