{"id":26346830,"url":"https://github.com/xuejiazhi/pgii","last_synced_at":"2025-03-16T07:14:37.222Z","repository":{"id":142340840,"uuid":"610731643","full_name":"xuejiazhi/pgii","owner":"xuejiazhi","description":"pgii is a PostgreSql cli tool. PostgreSql is developed in CMD or Golang and can be compiled for multiple platforms","archived":false,"fork":false,"pushed_at":"2024-11-20T01:24:08.000Z","size":36434,"stargazers_count":59,"open_issues_count":1,"forks_count":2,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-20T02:22:43.372Z","etag":null,"topics":["database","pg-cli","pgcli","pgii","postgres","postgresql","postgresql-cli","postgresql-database","timesale","timescaledb"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/xuejiazhi.png","metadata":{"files":{"readme":"readme.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-03-07T11:19:18.000Z","updated_at":"2024-11-20T01:24:12.000Z","dependencies_parsed_at":null,"dependency_job_id":"8501fe8d-2b84-4535-a471-8cc7d940a2bb","html_url":"https://github.com/xuejiazhi/pgii","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuejiazhi%2Fpgii","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuejiazhi%2Fpgii/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuejiazhi%2Fpgii/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/xuejiazhi%2Fpgii/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/xuejiazhi","download_url":"https://codeload.github.com/xuejiazhi/pgii/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243836025,"owners_count":20355616,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["database","pg-cli","pgcli","pgii","postgres","postgresql","postgresql-cli","postgresql-database","timesale","timescaledb"],"created_at":"2025-03-16T07:14:36.503Z","updated_at":"2025-03-16T07:14:37.209Z","avatar_url":"https://github.com/xuejiazhi.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"![image](https://user-images.githubusercontent.com/16795993/227710078-62d94904-c5df-46b2-a861-711eea7aee25.png)\n\n# A postgreSql Cli tool\n[![imi License](https://img.shields.io/badge/license-MIT-green)](https://github.com/xuejiazhi/pgii/blob/main/LICENSE)\nEnglish |[Import/Export Help](./dump.md)|[简体中文](./readme_cn.md)| [Help Document](https://github.com/xuejiazhi/pgii/wiki/pgii--postgreSql-Cli--Help-document)\n\npgii is a PostgreSql cli tool. PostgreSql is developed in CMD or Golang and can be compiled for multiple platforms：\n\n- **cross-platform**： Can be compiled under multiple platforms, cross-platform use；\n- **Zero-cost learning**：Similar to the MySQL Cli command, familiar with the mysql operation of the people on the hand；\n- **Interactive Console**: Through the console command line。[[Import/export help]](./dump.md)\n\n**Welcome to join us to develop**\n\n\n# Login\n**cmd**:\n~~~C\n  ./pgii [-h|--host] [-u|--user] [-p|--password] [-d|--db] [--port]\u003cbr/\u003e\n         [-h|--host]  Database address  # eg: -h localhost | --host=localhost\u003cbr/\u003e\n         [-u|--user] Database user  # eg: -u postgres | --user=postgres\u003cbr/\u003e\n         [-p|--password]  Database password  # eg: -p postgres | --password=postgres\u003cbr/\u003e\n         [-d|--db] select database Default:postgres # eg: -d postgres | --db=postgres\u003cbr/\u003e\n         [--port] Specified port # eg: --port=5432\u003cbr/\u003e\n~~~\n  #### example\n~~~C\n  $ pgii -h 127.0.0.1 -u postgres -p 123456 \n    Connect Pgsql Success Host 127.0.0.1\n    PostgresSql Version: 14.5\n    pgii~[postgres/]#\n~~~\n\n\n# set language\n### set language \u003ccn|en\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e   After setting the language with some commands, the header display of the command can be either Chinese or English\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# show db;\n+--------+-------------+----------+----------+------------+----------+-----------+-----------+------------+------------+---------+\n| #OID   | DBNAME      | AUTH     | ENCODING | LC_COLLATE | LC_CTYPE | ALLOWCONN | CONNLIMIT | LASTSYSOID | TABLESPACE | SIZE    |\n| 13891  | template0   | postgres | UTF8     | C          | C        | false     |        -1 | 13891      | pg_default | 8385 kB |\n+--------+-------------+----------+----------+------------+----------+-----------+-----------+------------+------------+---------+\n| 280382 | benchmark   | postgres | UTF8     | C          | C        | true      |        -1 | 13891      | pg_default | 10 MB   |\n+--------+-------------+----------+----------+------------+----------+-----------+-----------+------------+------------+---------+\npgii~[postgres/]# set language cn;\nSet Language Success\npgii~[postgres/]# show db;\n+--------+-------------+--------------+----------+------------+----------+----------+----------------+-----------------+------------+------------+\n| #OID   | 数据库      | 数据库拥用者 | 字符编码 | LC_COLLATE | LC_CTYPE | 允许连接 | 最大并发连接数 | 最后一个系统OID | 表空间     | 数据库尺寸 |\n+--------+-------------+--------------+----------+------------+----------+----------+----------------+-----------------+------------+------------+\n| 13892  | postgres[✓] | postgres     | UTF8     | C          | C        | true     |             -1 | 13891           | pg_default | 8537 kB    |\n+--------+-------------+--------------+----------+------------+----------+----------+----------------+-----------------+------------+------------+\n| 16384  | clouddb     | postgres     | UTF8     | C          | C        | true     |             -1 | 13891           | pg_default | 25 MB      |\n+--------+-------------+--------------+----------+------------+----------+----------+----------------+-----------------+------------+------------+\n| 1      | template1   | postgres     | UTF8     | C          | C        | true     |             -1 | 13891           | pg_default | 8385 kB    |\n+--------+-------------+--------------+----------+------------+----------+----------+----------------+-----------------+------------+------------+\n| 13891  | template0   | postgres     | UTF8     | C          | C        | false    |             -1 | 13891           | pg_default | 8385 kB    |\n+--------+-------------+--------------+----------+------------+----------+----------+----------------+-----------------+------------+------------+\n| 280382 | benchmark   | postgres     | UTF8     | C          | C        | true     |             -1 | 13891           | pg_default | 10 MB      |\n+--------+-------------+--------------+----------+------------+----------+----------+----------------+-----------------+------------+------------+\n~~~\n\n# Related instruction\n## use instruction\n### use \u003cdb|database\u003e \u003cdbName\u003e\n  ***FUNCTION：***\u003cbr/\u003e\n \u003e Used to select a database. After data is selected, you can run \"show db\" or \"show selectdb\" to view the selected database.\u003cbr/\u003e\n\n  ***USAGE：***\u003cbr/\u003e\n\u003e pgii~[postgres/]# use db benchmark\u003cbr/\u003e\n\u003e pgii~[postgres/]# use database benchmark\n\u003e\u003e    Use Database Success!\u003cbr/\u003e\n\n### use \u003csc|schema\u003e \u003cschemaName\u003e\n\n***FUNCTION：***\u003cbr/\u003e\n\u003e Used to select a database schema. After selecting a schema, you can run the \"show sc\" or \"show schema\" command to view the selected schema\n\n***USAGE：***\u003cbr/\u003e\n\u003e   pgii~[benchmark/]# use sc  public;\n\u003e\tpgii~[benchmark/]# use schema public;\n\u003e     # Use Schema Success!\n\n## show instruction\n### show \u003cdb|database\u003e\n***FUNCTION：***\u003cbr/\u003e\n  \u003e  Used to view information about the database, including the currently selected library and the size of the library\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# show database;\npgii~[postgres/]# show db;\n+-------+-------------+----------+----------+------------+----------+-----------+-----------+------------+------------+---------+\n| #OID  | DBNAME      | AUTH     | ENCODING | LC_COLLATE | LC_CTYPE | ALLOWCONN | CONNLIMIT | LASTSYSOID | TABLESPACE | SIZE    |\n+-------+-------------+----------+----------+------------+----------+-----------+-----------+------------+------------+---------+\n| 13892 | postgres[✓] | postgres | UTF8     | C          | C        | true      |        -1 | 13891      | pg_default | 8537 kB |\n| 16384 | clouddb     | postgres | UTF8     | C          | C        | true      |        -1 | 13891      | pg_default | 18 MB   |\n| 1     | template1   | postgres | UTF8     | C          | C        | true      |        -1 | 13891      | pg_default | 8385 kB |\n| 13891 | template0   | postgres | UTF8     | C          | C        | false     |        -1 | 13891      | pg_default | 8385 kB |\n| 91966 | benchmark   | postgres | UTF8     | C          | C        | true      |        -1 | 13891      | pg_default | 3370 MB |\n+-------+-------------+----------+----------+------------+----------+-----------+-----------+------------+------------+---------+\n~~~\n\n### show \u003csc|schema\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e Used to view schema information about the database, including the selected schema\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# show schema;\npgii~[postgres/]# show sc;\n┌───────┬──────────────────────────┬──────────┬─────────────────────────────────────┐\n│ #OID  │ SCHEMANAME               │ OWNER    │ ACL                                 │\n├───────┼──────────────────────────┼──────────┼─────────────────────────────────────┤\n│ 99    │ pg_toast                 │ postgres │ \u003cnil\u003e                               │\n│ 11    │ pg_catalog               │ postgres │ {postgres=UC/postgres,=U/postgres}  │\n│ 2200  │ public[✓]                │ postgres │ {postgres=UC/postgres,=UC/postgres} │\n│ 13526 │ information_schema       │ postgres │ {postgres=UC/postgres,=U/postgres}  │\n│ 91989 │ _timescaledb_cache       │ postgres │ {postgres=UC/postgres,=U/postgres}  │\n│ 91987 │ _timescaledb_catalog     │ postgres │ {postgres=UC/postgres,=U/postgres}  │\n│ 91988 │ _timescaledb_internal    │ postgres │ {postgres=UC/postgres,=U/postgres}  │\n│ 91990 │ _timescaledb_config      │ postgres │ {postgres=UC/postgres,=U/postgres}  │\n│ 91992 │ timescaledb_information  │ postgres │ {postgres=UC/postgres,=U/postgres}  │\n│ 91991 │ timescaledb_experimental │ postgres │ {postgres=UC/postgres,=U/postgres}  │\n└───────┴──────────────────────────┴──────────┴─────────────────────────────────────┘\n~~~\n\n### show \u003ctb|table\u003e [filter|equal] [value]\n***FUNCTION：***\u003cbr/\u003e\n\u003e This command is used to view information about tables in the database. If \"filter\" is used, the TABLENAME records containing value are filtered,and \"equal\" is all equal\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# show table;\npgii~[postgres/]# show tb;\npgii~[benchmark/public]# show tb;\n+--------+-----------+------------+------------+-----------+-----------+\n| SCHEMA | TABLENAME | TABLEOWNER | TABLESPACE | TABLESIZE | INDEXSIZE |\n+--------+-----------+------------+------------+-----------+-----------+\n| public | tags      | postgres   | \u003cnil\u003e      | 400 kB    | 264 kB    |\n+--------+-----------+------------+------------+-----------+-----------+\n| public | cpu       | postgres   | \u003cnil\u003e      | 32 kB     | 24 kB     |\n+--------+-----------+------------+------------+-----------+-----------+\npgii~[benchmark/public]# show tb filter c\n+--------+-----------+------------+------------+-----------+-----------+\n| SCHEMA | TABLENAME | TABLEOWNER | TABLESPACE | TABLESIZE | INDEXSIZE |\n+--------+-----------+------------+------------+-----------+-----------+\n| public | cpu       | postgres   | \u003cnil\u003e      | \u003cnil\u003e     | \u003cnil\u003e     |\n+--------+-----------+------------+------------+-----------+-----------+\n~~~\n\n### show \u003cvw|view\u003e [filter|equal] [value]\n***FUNCTION：***\u003cbr/\u003e\n\u003e This command is used to  view information about the database. The \"filter\" command is used to filter records whose VIEWNAME contains a value. \"equal\" is equal to all values\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# show view;\npgii~[postgres/]# show vw;\n+--------+----------+-----------+\n| SCHEMA | VIEWNAME | VIEWOWNER |\n+--------+----------+-----------+\n| public | cpu_view | postgres  |\n+--------+----------+-----------+\npgii~[benchmark/public]# show tb filter c\n+--------+----------+-----------+\n| SCHEMA | VIEWNAME | VIEWOWNER |\n+--------+----------+-----------+\n| public | cpu_view | postgres  |\n+--------+----------+-----------+\n~~~\n\n### show \u003ctg|trigger\u003e [filter|equal] [value]\n***FUNCTION：***\u003cbr/\u003e\n\u003e  This command is used to view information about triggers in the database. If \"filter\" is used, you can filter the records that contain a value in the trigger. \"equal\" is all equal\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# show tg;\npgii~[postgres/]# show trigger;\n+-----------+--------+-------------------+--------------------+--------------------+--------------------+---------------+\n| DATABASE  | SCHEMA | TRIGGER_NAME      | EVENT_MANIPULATION | EVENT_OBJECT_TABLE | ACTION_ORIENTATION | ACTION_TIMING |\n+-----------+--------+-------------------+--------------------+--------------------+--------------------+---------------+\n| benchmark | public | ts_insert_blocker | INSERT             | cpu                | ROW                | BEFORE        |\n+-----------+--------+-------------------+--------------------+--------------------+--------------------+---------------+\npgii~[benchmark/public]# show trigger filter ts;\n+-----------+--------+-------------------+--------------------+--------------------+--------------------+---------------+\n| DATABASE  | SCHEMA | TRIGGER_NAME      | EVENT_MANIPULATION | EVENT_OBJECT_TABLE | ACTION_ORIENTATION | ACTION_TIMING |\n+-----------+--------+-------------------+--------------------+--------------------+--------------------+---------------+\n| benchmark | public | ts_insert_blocker | INSERT             | cpu                | ROW                | BEFORE        |\n+-----------+--------+-------------------+--------------------+--------------------+--------------------+---------------+\n~~~\n\n### show \u003cver|version\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e    Used to view the version information about the database\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# show version;\npgii~[postgres/]# show ver;\n+-------------+---------+\n| #           | VERSION |\n+-------------+---------+\n| PostgresSql | 14.5    |\n+-------------+---------+\n~~~\n\n### show \u003csd|selectdb\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e    Used to view the currently selected database and schema for the database\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# show sd;\npgii~[benchmark/public]# show selectdb;\n    DataBase: benchmark ;Schema: public\n~~~\n\n### show \u003cconnection|conn\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e Some parameters to view the link\u003cbr/\u003e\n\u003e MAX_CONNECTION  ：  Maximum connection number\u003cbr/\u003e\n\u003e SUPERUSER_RESERVED_CONNECTIONS  ：   Number of connections reserved by the superuser\u003cbr/\u003e\n\u003e REMAINING_CONNECTIONS  ： Number of remaining connections\u003cbr/\u003e\n\u003e INUSE_CONNECTIONS   ： The number of connections currently in use\u003cbr/\u003e\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# show connection;\n+----------------+--------------------------------+-----------------------+-------------------+\n| MAX_CONNECTION | SUPERUSER_RESERVED_CONNECTIONS | REMAINING_CONNECTIONS | INUSE_CONNECTIONS |\n+----------------+--------------------------------+-----------------------+-------------------+\n|            800 |                             13 |                   760 |                40 |\n+----------------+--------------------------------+-----------------------+-------------------+\n~~~\n\n### show \u003cprocess|proc\u003e [all]|[pid start and end]\n***FUNCTION：***\u003cbr/\u003e\n\u003e 用于查看当前数据库中的会话:\n\u003e all: 如果没有带 all 参数,那么只显示当前选择数据库下面的会话，带了all显示所有的会话;\n\u003e pid: 列出pid 在 start 和 end 区间内的会话\n\u003e To view sessions in the current database:\n\u003e all: If the all parameter is not configured, only the sessions under the selected database are displayed. If the all parameter is configured, all sessions are displayed.\n\u003e pid: Lists the sessions whose pid is in the interval of start and end\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# show process;\n+--------+---------------+-----------+---------------+-------------+--------------------------------------+--------+\n| PID    | DATABASE_NAME | USER_NAME | CLIENT_ADDR   | CLIENT_PORT | APPLICATION_NAME                     | STATE  |\n+--------+---------------+-----------+---------------+-------------+--------------------------------------+--------+\n| 142668 | postgres      | postgres  | 10.161.55.214 | 56766       | DBeaver 22.0.2 - Main \u003cpostgres\u003e     | idle   |\n+--------+---------------+-----------+---------------+-------------+--------------------------------------+--------+\n| 142669 | postgres      | postgres  | 10.161.55.214 | 56767       | DBeaver 22.0.2 - Metadata \u003cpostgres\u003e | idle   |\n+--------+---------------+-----------+---------------+-------------+--------------------------------------+--------+\n| 206841 | postgres      | postgres  | 10.161.55.214 | 42969       |                                      | active |\n+--------+---------------+-----------+---------------+-------------+--------------------------------------+--------+\npgii~[postgres/]# show process all; \n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| PID    | DATABASE_NAME | USER_NAME | CLIENT_ADDR     | CLIENT_PORT | APPLICATION_NAME                           | STATE  |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 88720  |               |           |                 |             |                                            |        |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 117720 | clouddb       | postgres  | 100.123.237.153 | 38390       |                                            | idle   |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 90141  | clouddb       | postgres  | 100.123.237.196 | 54220       |                                            | idle   |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 142668 | postgres      | postgres  | 10.161.55.214   | 56766       | DBeaver 22.0.2 - Main \u003cpostgres\u003e           | idle   |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 142669 | postgres      | postgres  | 10.161.55.214   | 56767       | DBeaver 22.0.2 - Metadata \u003cpostgres\u003e       | idle   |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 142670 | clouddb       | postgres  | 10.161.55.214   | 56768       | DBeaver 22.0.2 - SQLEditor \u003cScript-24.sql\u003e | idle   |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 142671 | clouddb       | postgres  | 10.161.55.214   | 56769       | DBeaver 22.0.2 - Main \u003cclouddb\u003e            | idle   |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 142672 | clouddb       | postgres  | 10.161.55.214   | 56770       | DBeaver 22.0.2 - Metadata \u003cclouddb\u003e        | idle   |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 206841 | postgres      | postgres  | 10.161.55.214   | 42969       |                                            | active |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 33133  |               |           |                 |             |                                            |        |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\n| 33135  |               |           |                 |             |                                            |        |\n+--------+---------------+-----------+-----------------+-------------+--------------------------------------------+--------+\npgii~[postgres/]# show process pid 1 and 88585; \n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| PID   | DATABASE_NAME | USER_NAME | CLIENT_ADDR     | CLIENT_PORT | APPLICATION_NAME | STATE |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 88585 | clouddb       | postgres  | 100.123.237.162 | 54040       |                  | idle  |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 88583 | clouddb       | postgres  | 100.123.237.150 | 58828       |                  | idle  |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 88581 |               | postgres  |                 |             |                  |       |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 88579 | clouddb       | postgres  | 100.123.237.196 | 35001       |                  | idle  |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 88578 | clouddb       | postgres  | 100.123.237.148 | 48182       |                  | idle  |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 88577 | clouddb       | postgres  | 100.123.237.149 | 44360       |                  | idle  |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 88576 | clouddb       | postgres  | 100.123.237.154 | 43840       |                  | idle  |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 88575 | clouddb       | postgres  | 100.123.237.164 | 57554       |                  | idle  |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 33135 |               |           |                 |             |                  |       |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 33133 |               |           |                 |             |                  |       |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n| 33134 |               |           |                 |             |                  |       |\n+-------+---------------+-----------+-----------------+-------------+------------------+-------+\n~~~\n\n## desc instruction\n### desc \u003ctableName\u003e\n***FUNCTION：***\u003cbr/\u003e\n     Used to view the table structure\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# desc cpu;\n+----+------------------+-------------+--------+--------+--------------+\n| #  | COLUMN           | DATATYPE    | LENGTH | ISNULL | DEFAULTVALUE |\n+----+------------------+-------------+--------+--------+--------------+\n| 1  | time             | timestamptz | \u003cnil\u003e  | NO     | \u003cnil\u003e        |\n| 2  | tags_id          | int4        | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 3  | hostname         | text        | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 4  | usage_user       | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 5  | usage_system     | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 6  | usage_idle       | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 7  | usage_nice       | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 8  | usage_iowait     | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 9  | usage_irq        | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 10 | usage_softirq    | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 11 | usage_steal      | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 12 | usage_guest      | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 13 | usage_guest_nice | float8      | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n| 14 | additional_tags  | jsonb       | \u003cnil\u003e  | YES    | \u003cnil\u003e        |\n+----+------------------+-------------+--------+--------+--------------+\n~~~\n\n## size instruction\n### size \u003cdb|database\u003e \u003cdbName\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e     Used to view the size of the database\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# size database benchmark;\npgii~[benchmark/public]# size db benchmark;\n┌───────────┬─────────┐\n│ DATABASE  │ SIZE    │\n├───────────┼─────────┤\n│ benchmark │ 3370 MB │\n└───────────┴─────────┘\n~~~\n\n### size \u003ctb|table\u003e \u003ctableName\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e     Used to view the size of a database table\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# size table cpu;\npgii~[benchmark/public]# size tb cpu;\n┌───────────┬───────┐\n│ TABLENAME │ SIZE  │\n├───────────┼───────┤\n│ cpu       │ 32 kB │\n└───────────┴───────┘\n~~~\n\n### size \u003ctbsp|tablespace\u003e \u003ctableSpaceName\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e     Used to view the size of a table space name\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# size tablespace pg_default;\n+-----------------+-----------------+\n| TABLESPACE_NAME | TABLESPACE_SIZE |\n+-----------------+-----------------+\n| pg_default      | 60 MB           |\n+-----------------+-----------------+\n~~~\n\n## ddl instruction\n### ddl \u003ctb|table\u003e \u003ctableName\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e     A ddl construct clause for viewing the table\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# ddl table cpu;\npgii~[benchmark/public]# ddl tb cpu;\n========= Create Table Success ============\n-- DROP Table;\n-- DROP Table cpu;\nCREATE TABLE \"public\".cpu (\n    time timestamptz NOT NULL,\n    tags_id int4 NULL,\n    hostname text NULL,\n    usage_user float8 NULL,\n    usage_system float8 NULL,\n    usage_idle float8 NULL,\n    usage_nice float8 NULL,\n    usage_iowait float8 NULL,\n    usage_irq float8 NULL,\n    usage_softirq float8 NULL,\n    usage_steal float8 NULL,\n    usage_guest float8 NULL,\n    usage_guest_nice float8 NULL,\n    additional_tags jsonb NULL\n);\nCREATE INDEX cpu_usage_user_time_idx ON public.cpu USING btree (usage_user, \"time\" DESC);\nCREATE INDEX cpu_time_idx ON public.cpu USING btree (\"time\" DESC);\nCREATE INDEX cpu_hostname_time_idx ON public.cpu USING btree (hostname, \"time\" DESC);\n~~~\n\n### ddl \u003csc|schema\u003e \u003cschemaName\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e     A ddl constructor clause for viewing the schema\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# ddl schema public;\npgii~[benchmark/public]# ddl sc public;\n========= Create Schema Success ============\n-- DROP SCHEMA public;\nCREATE SCHEMA \"public\" AUTHORIZATION postgres;\n~~~\n\n### ddl \u003cvw|view\u003e \u003cviewName\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e     The ddl constructor clause for viewing the view\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[benchmark/public]# ddl view cpu_view;\npgii~[benchmark/public]# ddl vw cpu_view;\n========= Create View Success ============\n CREATE OR REPLACE VIEW \"public\".cpu_view\n AS SELECT cpu.\"time\",\n    cpu.tags_id,\n    cpu.hostname,\n    cpu.usage_user,\n    cpu.usage_system,\n    cpu.usage_idle,\n    cpu.usage_nice,\n    cpu.usage_iowait,\n    cpu.usage_irq,\n    cpu.usage_softirq,\n    cpu.usage_steal,\n    cpu.usage_guest,\n    cpu.usage_guest_nice,\n    cpu.additional_tags\n   FROM cpu\n  WHERE ((cpu.\"time\" \u003e '2023-03-01 08:00:00+08'::timestamp with time zone) AND (cpu.tags_id \u003e 10) AND (cpu.tags_id \u003c 1000) AND (cpu.usage_user = ANY (ARRAY[(21)::double precision, (22)::double precision, (23)::double precision, (24)::double precision, (25)::double precision, (26)::double precision, (27)::double precision, (28)::double precision, (29)::double precision])));\n~~~\n\n## kill instruction\n### kill pid \u003cpid\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e   To close a session in the database, run \"show proc\" to check whether it is closed\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[postgres/]# kill pid 33134;\nKill Process Success,pid[33134]\n~~~\n\n## clear instruction\n### clear \u003ctb|table\u003e \u003ctableName\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e   This command clears all data in a table, similar to TRUNCATE\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgi~[xc/test]# show tb;\n+------------+-----------+------------+------------+-----------+-----------+\n| SCHEMA     | TABLENAME | TABLEOWNER | TABLESPACE | TABLESIZE | INDEXSIZE |\n+------------+-----------+------------+------------+-----------+-----------+\n| test       | test      | postgres   | \u003cnil\u003e      | 16 kB     | 0 bytes   |\n+------------+-----------+------------+------------+-----------+-----------+\n| test       | t_test    | postgres   | \u003cnil\u003e      | 356 MB    | 107 MB    |\n+------------+-----------+------------+------------+-----------+-----------+\npgi~[xc/test]# select count(*) from t_test;\n+---------+\n|   COUNT |\n+---------+\n| 5000000 |\n+---------+\npgi~[xc/db_mcs.com]# clear tb t_test;\nClear table success\npgi~[xc/db_mcs.com]# select count(*) from t_test; \n+-------+\n| COUNT |\n+-------+\n|     0 |\n+-------+\n[Total: 1 Rows]  [RunTimes 0.10s]\n~~~\n\n~~~\n### explain \u003cT-SQL\u003e\n***FUNCTION：***\u003cbr/\u003e\n\u003e  It is used to analyze T-SQL execution plans\n\n***USAGE：***\u003cbr/\u003e\n~~~C\npgii~[clouddb/db_mcs.com]# explain ANALYZE select * from userprofile;\n+---------------------------------------------------------------------------------------------------------------+\n| QUERY PLAN                                                                                                    |\n+---------------------------------------------------------------------------------------------------------------+\n| Seq Scan on userprofile  (cost=0.00..105.41 rows=2241 width=230) (actual time=0.024..0.705 rows=2241 loops=1) |\n| Planning time: 0.131 ms                                                                                       |\n| Execution time: 0.882 ms                                                                                      |\n+---------------------------------------------------------------------------------------------------------------+\n[Total: 3 Rows]  [RunTimes 3.50s]\n\npgii~[clouddb/db_mcs.com]# explain  select * from userprofile;        \n+------------------------------------------------------------------+\n| QUERY PLAN                                                       |\n+------------------------------------------------------------------+\n| Seq Scan on userprofile  (cost=0.00..105.41 rows=2241 width=230) |\n+------------------------------------------------------------------+\n[Total: 1 Rows]  [RunTimes 2.18s]\n~~~\n\n## TODO\n-  dump table ✅\n-  dump scheam ✅\n-  kill pid ✅\n-  show process ✅\n-  load table ✅\n-  load schema✅\n-  load database\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuejiazhi%2Fpgii","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fxuejiazhi%2Fpgii","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fxuejiazhi%2Fpgii/lists"}