ITPub博客

首页 > 数据库 > 数据库开发技术 > openGauss学习笔记-14 openGauss 简单数据管理-查看对象

openGauss学习笔记-14 openGauss 简单数据管理-查看对象

原创 数据库开发技术 作者:shuchaoyang 时间:2023-04-03 07:30:00 0 删除 编辑

openGauss学习笔记-14 openGauss 简单数据管理-查看对象14.1 查看命令帮助信息14.2 切换数据库14.3 查询所有数据库14.4 查询当前数据库中的所有表14.5 查看表结构

openGauss学习笔记-14 openGauss 简单数据管理-查看对象

gsql工具提供了若干高级特性,便于用户使用。常见用法如下:

14.1 查看命令帮助信息

\h [NAME]

例如,查询ABORT的所有语法。

openGauss=# \h ABORT
Command:     ABORT
Description: abort the current transaction
Syntax:
ABORT [ WORK | TRANSACTION ] ;

14.2 切换数据库

\c dbname

例如,将postgres数据库切换为数据库dp_tpcc。

openGauss=# \c db_tpcc
Non-SSL connection (SSL connection is recommended when requiring high-security)
You are now connected to database "db_tpcc" as user "omm".
db_tpcc=#

14.3 查询所有数据库

\l

示例如下。

openGauss=# \l
                        List of databases
  Name   | Owner | Encoding | Collate | Ctype | Access privileges
-----------+-------+-----------+---------+-------+-------------------
mydb     | omm   | GBK       | C       | C     |
postgres | omm   | SQL_ASCII | C       | C     |
template0 | omm   | SQL_ASCII | C       | C     | =c/omm           +
          |       |           |         |       | omm=CTc/omm
template1 | omm   | SQL_ASCII | C       | C     | =c/omm           +
          |       |           |         |       | omm=CTc/omm
(4 rows)

14.4 查询当前数据库中的所有表

\dt

示例如下。

openGauss=# \dt
                            List of relations
Schema |     Name       | Type | Owner |             Storage
--------+-----------------+-------+-------+----------------------------------
public | customer_t1     | table | omm   | {orientation=row,compression=no}
public | customer_t1_bak | table | omm   | {orientation=row,compression=no}
(2 rows)

14.5 查看表结构

\d tablename

例如,查看表customer_t1的表结构。

openGauss=# \d customer_t1
Table "public.customer_t1"
Column | Type | Modifiers
---------------+--------------+-----------
c_customer_sk | integer |
c_customer_id | character(5) |
c_first_name | character(6) |
c_last_name | character(8) |
amount | integer |


👍 点赞,你的认可是我创作的动力!

⭐️ 收藏,你的青睐是我努力的方向!


有什么吐槽或反馈意见,直接告诉我!

温馨提示:如出现二维码失效也可直接添加微信号:ysc13803862469。


原文作者:超哥的IT私房菜;如有侵权,请联系管理员删除。

请登录后发表评论 登录
全部评论
专注于IT系统集成、运维、架构二十年的IT职场老兵,拥有CCNA、OCA、OCP、PGCA、PGCE认证证书,公众号:超哥的IT私房菜,知识星球:超哥的IT私房菜,目前是多家IT厂商的咨询顾问。

注册时间:2021-08-27

  • 博文量
    552
  • 访问量
    303582