1.gsql命令连到数据库omm
–使用omm用户连接到本机omm数据库的5432端口,命令中的-r选项提供了对gsql命令的历史版本支持。
su - omm gsql -r 或 gsql -d omm -p 5432 -r
复制
2.查看数据库的版本、版权信息
select version(); show server\_version; \copyright
复制
3.常见元命令使用
\pset border 里有好几种选择
\x 打开扩展表格式模式,再次执行\x 关闭扩展
4.使用两种方法,连到postgres数据库中,连上切库或者直接连
gsql -r \c postgres 或 gsql -d postgres -p 5432 -r
复制
5.测试gsql中的默认事务自动提交功能
openGauss=# --查看gsql中事务是否默认为自动提交
openGauss=# show AUTOCOMMIT; +------------+ | autocommit | +------------+ | on | +------------+ (1 row)
复制
openGauss=# --测试gsql中事务默认为自动提交功能
openGauss=# create table customer\_new as select \* from customer\_t; INSERT 0 1 openGauss=# \q
复制
omm@modb:~$ --重新登录后看到之前创建的表customer_new:
omm@modb:~$ gsql -d postgres -p 5432 -r gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. openGauss=# \dt List of relations Schema | Name | Type | Owner | Storage \--------+--------------+-------+-------+---------------------------------- public | customer\_new | table | omm | {orientation=row,compression=no} public | customer\_t | table | omm | {orientation=row,compression=no} (2 rows)
复制
6.测试gsql中的事务手动提交功能
–测试gsql手动提交
#Opengauss默认执行完一条语句后,立即提交。可以关闭自动提交功能:
#注意:此处设置AUTOCOMMIT必须用大写!
show autocommit可以小写
omm=# \set autocommit off omm=# show AUTOCOMMIT; autocommit ------------ on (1 row) omm=# show autocommit; autocommit ------------ on (1 row)
复制
7.了解gsql相关帮助
omm@modb:~$ gsql --help gsql is the openGauss interactive terminal. Usage: gsql [OPTION\]... [DBNAME [USERNAME]] General options: -c, --command=COMMAND run only single command (SQL or internal) and exit omm@modb:~$ gsql -r gsql ((openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 last mr ) Non-SSL connection (SSL connection is recommended when requiring high-security) Type "help" for help. omm=# \h Available help: ABORT CREATE DATA SOURCE DROP NODE GROUP omm=# \? 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
复制
最后修改时间:2022-11-28 12:14:45
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论

2年前

评论
相关阅读
openGauss荣获中国软件行业协会多奖项,技术升级再创行业新高度
openGauss
557次阅读
2025-04-30 14:30:58
MogDB 发布更新,解决 openGauss 数据库在长事务情况下Ustore表膨胀问题
MogDB
308次阅读
2025-04-17 10:41:41
MogDB 发布更新,解决 openGauss 数据库在长事务情况下Ustore表膨胀问题
云和恩墨
201次阅读
2025-04-16 09:52:02
GitCode 成 openGauss 新归宿,国产开源数据库里程碑事件
严少安
174次阅读
2025-04-27 11:37:53
荣誉时刻!openGauss认证证书快递已发,快来看看谁榜上有名!
墨天轮小教习
162次阅读
2025-04-23 17:39:13
单个执行机并行执行MySQL到openGauss数据迁移子任务
Clipnosis
151次阅读
2025-04-30 16:39:58
Postgresql数据库单个Page最多存储多少行数据
maozicb
96次阅读
2025-04-23 16:02:19
openGauss6.0.0适配操作系统自带的软件,不依赖三方库
来杯拿铁
96次阅读
2025-04-18 10:49:53
openGauss新特性 | openGauss-DataVec向量数据库特性介绍
openGauss
67次阅读
2025-04-17 10:41:47
RISC-V 首迎 openGauss 7.0.0-RC1 全量版适配!数据库核心功能完整落地开源架构
openGauss
50次阅读
2025-04-16 10:33:59