【赵渝强老师】高斯数据库(openGauss)的模式

openGauss的逻辑存储结构主要是指数据库中的各种数据库对象,包括:数据库集群、数据库、表、索引、视图等等。所有数据库对象都有各自的对象标识符oid(object identifiers),它是一个无符号的四字节整数,相关对象的oid都存放在相关的系统目录表中,比如数据库的oid和表的oid分别存放在pg_database,pg_class表中。下图展示了openGauss数据库的逻辑存储结构。

模式Schema是数据库中的命名空间,在数据库中创建的所有对象都是在Schema中创建。一个用户可以从同一个客户端连接中访问不同的Schema。而不同的Schema中可以有多个同名的表、索引、视图、序列、函数等等各种不同的数据库对象。

视频讲解如下
【赵渝强老师】高斯数据库(openGauss)的模式

可以通过下面的方式来查看当前数据库的Schema。

sql 复制代码
openGauss=# \dn

# 输出的信息如下:  
     List of schemas
      Name       | Owner  
-----------------+--------
 blockchain      | postgres
 coverage        | postgres
 cstore          | postgres
 db4ai           | postgres
 dbe_perf        | postgres
 dbe_pldebugger  | postgres
 dbe_pldeveloper | postgres
 dbe_sql_util    | postgres
 myuser          | myuser
 pkg_service     | postgres
 public          | postgres
 snapshot        | postgres
 sqladvisor      | postgres
(13 rows)

在默认情况下,OpenGauss会自动创建12个模式。下表说明了其中主要模式的功能和作用。

下面的步骤将创建一个新的模式,并在该模式下创建一张表。

(1)创建一个新的模式。

sql 复制代码
openGauss=# create schema myschema;

(2)在该模式下创建一张表。

sql 复制代码
openGauss=# create table myschema.test1(tid int);

(3)查看指定模式下的表。

sql 复制代码
openGauss=# \dt myschema.*
                          List of relations
  Schema  | Name  | Type  | Owner   |             Storage              
----------+-------+-------+---------+----------------------------------
 myschema | test1 | table |postgres | {orientation=row,compression=no}
(1 row)
相关推荐
多弗朗皮卡丘6 小时前
MySQL表的约束
数据库·mysql
Flynn Liang10 小时前
AI Agent Redis 生产踩坑实录:13 类故障的根因、复现与调优
数据库·人工智能·redis·缓存·ai agent·故障分析
SelectDB11 小时前
开源日志平台怎么选?ELK、Loki、ClickHouse、Apache Doris 四大方案对比与选型指南
数据库
SelectDB12 小时前
ELK 磁盘空间不足怎么办?Elasticsearch 存储膨胀原因、排查步骤与 3 种降本方案
数据库
满小满12 小时前
为什么我先 ANALYZE,而不是先加索引
数据库·dba
SelectDB12 小时前
日志分析用什么数据库好?Elasticsearch、ClickHouse、Doris 选型对比与 3 个企业案例
数据库
inferno14 小时前
十三、存储过程(PROCEDURE)
数据库·sql·mysql
数据库急诊室_阿哲15 小时前
一周慢查询日志审计:1200 条里有多少真问题
运维·数据库·dba
zhangjw3415 小时前
2-4 集合运算 union /union all /intersect/except
数据库·postgresql
Decay__16 小时前
PostgreSQL DBA 日常运维手册 —— 会话、锁阻塞、慢查询、膨胀与每日巡检
运维·数据库·sql·postgresql