openGauss gsql 常用元命令 二

openGauss gsql 常用元命令 二

\df 查看当前数据库函数信息

openGauss=# \df
********* QUERY **********
SELECT n.nspname as "Schema",p.proname as "Name",pg_catalog.pg_get_function_result(p.oid) as "Result data type",pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types",CASEWHEN p.proisagg THEN 'agg'WHEN p.proiswindow THEN 'window'WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger'ELSE 'normal'
END as "Type" ,fencedmode as "fencedmode",propackage as "propackage",prokind as "prokind"FROM pg_catalog.pg_proc pLEFT JOIN pg_catalog.pg_namespace n ON n.oid = p.pronamespace
WHERE pg_catalog.pg_function_is_visible(p.oid)AND n.nspname <> 'pg_catalog'AND n.nspname <> 'db4ai'AND n.nspname <> 'information_schema'
ORDER BY 1, 2, 4;
**************************List of functionsSchema |   Name    | Result data type |               Argument data types                |  Type  | fencedmode | propackage | prokind
--------+-----------+------------------+--------------------------------------------------+--------+------------+------------+---------public | fuc_worth | numeric          | price numeric, amount integer, OUT worth numeric | normal | f          | f          | f
(1 row)

\dx 查看已安装的扩展程序信息

openGauss=# \dx
********* QUERY **********
SELECT e.extname AS "Name", e.extversion AS "Version", n.nspname AS "Schema", c.description AS "Description"
FROM pg_catalog.pg_extension e LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass
ORDER BY 1;
**************************List of installed extensionsName       | Version |   Schema   |                   Description
-----------------+---------+------------+--------------------------------------------------dist_fdw        | 1.0     | pg_catalog | foreign-data wrapper for distfs accessfile_fdw        | 1.0     | pg_catalog | foreign-data wrapper for flat file accesshdfs_fdw        | 1.0     | pg_catalog | foreign-data wrapper for flat file accesshstore          | 1.1     | pg_catalog | data type for storing sets of (key, value) pairslog_fdw         | 1.0     | pg_catalog | Foreign Data Wrapper for accessing logging datamot_fdw         | 1.0     | pg_catalog | foreign-data wrapper for MOT accessplpgsql         | 1.0     | pg_catalog | PL/pgSQL procedural languagesecurity_plugin | 1.0     | pg_catalog | provides security functionality
(8 rows)

\x 语法 \x[on|off|auto] 设置语句的输出模式,模式为行的方式输出,执行 \x on 切换为以列的方式来显示

openGauss=# \x
Expanded display is on.
openGauss=# \dx
********* QUERY **********
SELECT e.extname AS "Name", e.extversion AS "Version", n.nspname AS "Schema", c.description AS "Description"
FROM pg_catalog.pg_extension e LEFT JOIN pg_catalog.pg_namespace n ON n.oid = e.extnamespace LEFT JOIN pg_catalog.pg_description c ON c.objoid = e.oid AND c.classoid = 'pg_catalog.pg_extension'::pg_catalog.regclass
ORDER BY 1;
**************************List of installed extensions
-[ RECORD 1 ]-------------------------------------------------
Name        | dist_fdw
Version     | 1.0
Schema      | pg_catalog
Description | foreign-data wrapper for distfs access
-[ RECORD 2 ]-------------------------------------------------
Name        | file_fdw
Version     | 1.0
Schema      | pg_catalog
Description | foreign-data wrapper for flat file access
-[ RECORD 3 ]-------------------------------------------------

\timing 语法 \timing [on|off] 控制显示 SQL 的执行时间,默认为 off, on 为显示 SQL 语句的执行时间

openGauss=# select * from test;id
----1
(1 row)openGauss=# \timing on
Timing is on.
openGauss=# select * from test;id
----1
(1 row)Time: 0.352 ms

\h 用于获取 SQL 语句的帮助,例如 \h merge

openGauss=# \h merge
Command:     MERGE
Description: insert, update, or delete rows of a table based upon source data
Syntax:
MERGE [/*+ plan_hint */] INTO table_name [ [ AS ] alias ]
USING { { table_name | view_name } | subquery } [ [ AS ] alias ]
ON ( condition )
[WHEN MATCHED THENUPDATE SET { column_name = { expression | DEFAULT } |( column_name [, ...] ) = ( { expression | DEFAULT } [, ...] ) } [, ...][ WHERE condition ]
]
[WHEN NOT MATCHED THENINSERT { DEFAULT VALUES |[ ( column_name [, ...] ) ] VALUES ( { expression | DEFAULT } [, ...] ) [, ...] [ WHERE condition ] }
];

? 获取 gsql 的元命令的帮助

openGauss=# \?
General\copyright             show openGauss usage and distribution terms\g [FILE] or ;         execute query (and send results to file or |pipe)\h(\help) [NAME]              help on syntax of SQL commands, * for all commands\parallel [on [num]|off] toggle status of execute (currently off)\q                     quit gsqlQuery Buffer\e [FILE] [LINE]       edit the query buffer (or file) with external editor\ef [FUNCNAME [LINE]]  edit function definition with external editor\p                     show the contents of the query buffer\r                     reset (clear) the query buffer\w FILE                write query buffer to fileInput/Output\copy ...              perform SQL COPY with data stream to the client host\echo [STRING]         write string to standard output\i FILE                execute commands from file\i+ FILE KEY           execute commands from encrypted file\ir FILE               as \i, but relative to location of current script\ir+ FILE KEY          as \i+, but relative to location of current script\o [FILE]              send all query results to file or |pipe\qecho [STRING]        write string to query output stream (see \o)

! os_command 用于执行操作系统命令,同 oracle 的 !,mysql 的 system

openGauss-# \! pwd
/home/omm
openGauss-# \! ls
1.sh  create_db_tables.sql  test.sql

\o filename 用于重定向输出到文件,注意这个不是简单的将屏幕的内容输出到文本,而是将 SQL 语句正确执行的结果输出到文本

openGauss-# \o test.out
openGauss-# select * from test;
WARNING:  Session unused timeout.
FATAL:  terminating connection due to administrator command
could not send data to server: Broken pipe
The connection to the server was lost. Attempting reset: Succeeded.
openGauss=# select * from test;
openGauss=# \! cat test.outid
----1
(1 row)openGauss=# select * from pg_tables;
openGauss=#  \! cat test.outid
----1
(1 row)schemaname     |           tablename           | tableowner | tablespace | hasindexes | hasrules | hastriggers | tablecreator |            created            |         last_ddl_time
--------------------+-------------------------------+------------+------------+------------+----------+-------------+--------------+-------------------------------+-------------------------------pg_catalog         | pg_statistic                  | omm        |            | t          | f        | f           |              |                               |\i file.sql

\conninfo 显示 gsql 中显示会话的连接信息

\c[onnect] [DBNAME] 切换数据库

openGauss=# \conninfo
You are connected to database "postgres" as user "omm" via socket in "/opt/huawei/tmp" at port "15400".
openGauss=# \c mydb
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "mydb" as user "omm".
mydb=# \conninfo
You are connected to database "mydb" as user "omm" via socket in "/opt/huawei/tmp" at port "15400".

\echo [string] 打印字符串

mydb=# \echo Hello World!
Hello World!

\q 退出 gsql

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/726932.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

wsl 安装 ubuntu

文章目录 打开Windows PowerShell查看可安装的ubuntu安装相对应的ubuntu将用户添加到sudoers文件中&#xff0c;并赋予了该用户sudo权限。 打开Windows PowerShell 以管理员的身份运行 查看可安装的ubuntu wsl.exe --list --online安装相对应的ubuntu wsl --install 版本…

蓝桥杯错误记录

今天在做 小蜜蜂的综合案例的时候&#xff0c;数码管显示&#xff0c;有重影。 #include <STC15F2K60S2.H> unsigned char num; unsigned char code Duan[22]{0xc0,0xf9,0xa4,0xb0,0x99,0x92,0x82,0xf8,0x80,0x90,0x88,0x80, 0xc6,0xc0,0x86,0x8e,0xbf,0x7f,0XC1,0X8C,0…

【云服务】-云服务 的基础

企业IT架构的演进历史 云计算的定义 云计算是一种模型&#xff0c;可以实现随时随地便携地可配置资源共享池中所需的资源&#xff08;例如&#xff0c;网络、服务器、存储、应用及服务&#xff09;。资源能快速供应并且释放&#xff0c;使管理资源的工作量和与服务提供商的交…

中小企业应该如何应用人才测评系统

人才测评系统应用场景越来越多&#xff0c;很多企业也开始通过人才测评系统&#xff0c;来对员工的性格特点和岗位进行评估&#xff0c;比如作为项目经理的我&#xff0c;总是想先从员工内部选拔领导者&#xff0c;然而这就有很大的难度&#xff0c;那么团队建设之初&#xff0…

Python小白福利之enumerate函数

enumerate函数用于遍历序列中的元素以及它们的下标。 enumerate函数说明&#xff1a; 函数原型&#xff1a;enumerate(sequence, [start0]) 功能&#xff1a;将可循环序列sequence以start开始分别列出序列数据和数据下标 即对一个可遍历的数据对象(如列表、元组或字符串)&a…

protobufjs使用教程,支持proto文件打包成typescript或javascript脚本

官方链接&#xff1a;https://docs.cocos.com/creator/manual/zh/scripting/modules/example.html 第一步&#xff0c;安装nodejs。&#xff08;自行安装&#xff09; 安装教程可参考 https://www.runoob.com/nodejs/nodejs-install-setup.html 第二步&#xff0c;创建cocos…

AD导入FreeCAD生成的step文件后颜色丢失?

最近在绘制一个模组&#xff0c;本身是想在网上找是否有类似的3D模型&#xff0c;但是似乎没有&#xff0c;此时我就自己用FreeCAD画了一个&#xff0c;但是在导入到AD中就出现了问题 使用freecad画出的模型样式&#xff1a; 导入到AD中去后的样式&#xff1a; freecad中导出时…

NC6及以上版本 关于文件服务器处理逻辑与顺序

关于文件服务器处理逻辑与顺序&#xff1a; 先在sm_pub_filesystem中创建目录或上传的文件内容&#xff0c;此表为文件或文件夹真实路径信息&#xff0c;其核心在于filepath与pk_doc的值&#xff0c;filepath为前端可查看真实的路径值&#xff0c;pk_doc是该文件在文件服务中的…

PageHelper 分页查询原理介绍

1. 简介 PageHelper方法使用了静态的ThreadLocal参数,分页参数和线程是绑定的。内部流程是ThreadLocal中设置了分页参数(pageNum,pageSize),之后在查询执行的时候,获取当前线程中的分页参数,执行查询的时候通过拦截器在sql语句中添加分页参数,之后实现分页查询,查询结…

passwd: Authentication token manipulation error

passwd: Authentication token manipulation error 身份验证令牌操作错误。 可能原因&#xff1a; 1、密码文件无修改权限&#xff08;有i权限&#xff09; lsattr /etc/{passwd,shadow} 取消方法 chattr -i /etc/passwd chattr -i /etc/passwd 2、/文件系统无空间或者无inod…

GOWIN软件使用

1、管脚复用 根据自己需求把复用管脚勾选上&#xff0c;管脚当普通管脚使用 JTAG设置成普通管脚&#xff0c;下载程序时候JTAGEN管脚需要上拉高电平&#xff08;可以在下载器线上上拉个电阻&#xff0c;下载后把下载线拔走&#xff0c;否则JTAG管脚无法使用&#xff0c;管脚充…

Linux - 反弹Shell

概念 Shell 估计大家都不陌生&#xff0c;简单来说&#xff0c;就是实现用户命令的接口&#xff0c;通过这个接口我们就能实现对计算机的控制&#xff0c;比如我们常见的 ssh 就是执行的 Shell 命令实现对远程对服务器的控制。 那反弹 Shell &#xff08; Reverse Shell&…

前端将html导出pdf文件解决分页问题

这是借鉴了qq_251025116大佬的解决方案并优化升级完成的&#xff0c;原文链接 1.安装依赖 npm install jspdf html2canvas2.使用方法 import htmlToPdffrom ./index.jsconst suc () > {message.success(success);};//记得在需要打印的div上面添加 idlet dom document.que…

2024内衣洗衣机测评推荐:希亦、小吉、鲸立综合对比哪个牌子好?

对于那些追求品质生活、分类洗涤的用户而言&#xff0c;小型洗衣机可以满足我们对不同类型衣物分开洗涤的需求&#xff0c;例如将内衣、袜子等小件衣物与外套等分开洗涤&#xff0c;以保持衣物的清洁和卫生。并且如果您家中有宝宝&#xff0c;或者您对个人卫生和健康有较高要求…

Spring面向切片编程AOP概念及相关术语(一)

个人名片&#xff1a; &#x1f43c;作者简介&#xff1a;一名大三在校生&#xff0c;喜欢AI编程&#x1f38b; &#x1f43b;‍❄️个人主页&#x1f947;&#xff1a;落798. &#x1f43c;个人WeChat&#xff1a;hmmwx53 &#x1f54a;️系列专栏&#xff1a;&#x1f5bc;️…

Java学习路线-最基础版

Java学习路线-最基础版 文章目录 Java学习路线-最基础版前言一、基础篇1. Java语言基础2.集合框架&#xff08;List、Set、Map等&#xff09; 二、进阶篇1. 深入面向对象2. Java Web基础3. Java EE技术 三、高级篇1. Java Web框架2. 分布式系统3. 并发及大数据处理 四、推荐1. …

使用Vue CLI创建vue项目具体步骤及选项解释

环境&#xff1a; node.js&#xff1a;14.21 Vue CLI&#xff1a;4.5.9 1、执行创建命令 vue create xxx&#xff08;项目名称&#xff09;2、选择一个预设 Vue CLI v4.5.9 ┌─────────────────────────────────────────…

分享几种简约大方的ListView外观设计(qml)

一、前言 最近才学到这里&#xff0c;感觉基础的 ListView 很丑&#xff0c;就现学现用弄个几个自认为还行的设计给大家献丑了。如果你觉得还不错&#xff0c;代码就在下面拿去直接用&#xff0c;顺便给我点个赞哈 ~ 感谢感谢 ~ 二、正文 设计1 第一种就是正常的左侧边栏&am…

redis知识点

一、关系型数据库和非关系型数据库 关系型数据库&#xff08;RDBMS&#xff09;&#xff1a;指采用了关系模型来组织数据的数据库&#xff0c;&#xff0c;关系模型指的就是二维表格模型&#xff0c;而一个关系型数据库就是由二维表及其之间的联系所组成的一个数据组织。 ①特…

无纸化电子sop系统帮助企业降低成本,提高目视化管理

无纸化电子SOP系统是一种基于数字化技术的生产管理系统&#xff0c;旨在优化员工的生产规范&#xff0c;提高产品质量。随着制造业的发展和数字化转型&#xff0c;越来越多的企业开始采用无纸化电子SOP系统来替代传统的纸质操作规程&#xff0c;以提升生产效率、降低成本、确保…