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

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

模式Schema是数据库中的命名空间,在数据库中创建的所有对象都是在Schema中创建。一个用户可以从同一个客户端连接中访问不同的Schema。而不同的Schema中可以有多个同名的表、索引、视图、序列、函数等等各种不同的数据库对象。
![]() |
|---|
| 点击这里查看视频讲解:【赵渝强老师】高斯数据库(openGauss)的模式 |
可以通过下面的方式来查看当前数据库的Schema。
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)创建一个新的模式。
openGauss=# create schema myschema;
(2)在该模式下创建一张表。
openGauss=# create table myschema.test1(tid int);
(3)查看指定模式下的表。
openGauss=# \dt myschema.*
List of relations
Schema | Name | Type | Owner | Storage
----------+-------+-------+---------+----------------------------------
myschema | test1 | table |postgres | {orientation=row,compression=no}
(1 row)


浙公网安备 33010602011771号