暂无图片
暂无图片
1
暂无图片
暂无图片
暂无图片

openGauss每日一练第2天

原创 Scott_jin 2022-11-28
236

学习gsql的使用

1.使用gsql登录实例

root@modb:~# su - omm
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=# 



root@modb:~# su - omm
omm@modb:~$ gsql -d omm -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.

omm=# 

2. 使用gsql查看数据库版本的方法:

omm=# select version();
----------------------------------------------------------------------------
---------------------------------------------------------------------------
(openGauss 3.0.0 build 02c14696) compiled at 2022-04-01 18:12:00 commit 0 l
ast mr on aarch64-unknown-linux-gnu, compiled by g++ (GCC) 7.3.0, 64-bit
(1 row)

vers
ion
omm=# show server_version;
server_version
----------------
9.2.4
(1 row)

omm=# \copyright
GaussDB Kernel Database Management System
Copyright (c) Huawei Technologies Co., Ltd. 2018. All rights reserved.

3. gsql 常用元命令的学习:

\l 实现当前实例下的所有数据库

\conninfo 显示当前应用连接的信息

\c postgres 连接postgres数据库

\du \dg 显示user ,role的信息

\db 显示表空间

\dn 显示schema

\dt 显示数据库中的表

\d customer_t 显示表的

4. 使用gsql命令行创建表,插入数据信息

omm=# create table customer_tomm-#
( c_customer_sk integer,omm(#
c_custome_id char(5),
omm(# c_first_name char(6),
omm(# c_last_name char(8));
omm=# CREATE TABLE

omm=# INSERT INTO customer_t VALUES (3769, 5, 'Grace','White');
INSERT 0 1
omm=# select * from customer_t ;
c_customer_sk | c_custome_id | c_first_name | c_last_name
---------------+--------------+--------------+-------------
3769 | 5 | Grace | White
(1 row)
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论