暂无图片
暂无图片
5
暂无图片
暂无图片
暂无图片

梧桐数据库中初始化生成的数据库

Rhein 2025-05-20
68

一个WuTongDB集群管理着多个数据库(database),WuTong DB 在初始化完成后,会默认生成三个数据库,可以使用l 命令查看,或者查看pg_database 系统表。

 postgres=# \l

 List of databases

 Name | Owner | Encoding | Access privileges

 -----------+----------+----------+-------------------

 postgres | ChangLei | UTF8 |

 template0 | ChangLei | UTF8 |

 template1 | ChangLei | UTF8 |

 (4 rows)

其中template0 和template1 为模版数据库。template1 为系统默认用来创建新数据库的模版数据库,用户可以修改。template0 默认不接受连接,所以不可更改,目的是始终保存一个干净的模版数据库。

创建一个数据库的时候,可以指定一个数据库的模版数据库。缺省为template1,现在WuTongDB 只支持以template0,template1 和postgres 数据库为模版数据库。例如:

 postgres=# create database tdb; # 创建一个新数据库, 默认以template0为模版

 CREATE DATABASE

 postgres=#\c postgres # 连接postgres

 postgres=# create table test(i int); # 在postgres数据库中创建表test

 CREATE TABLE

 postgres=# create table test_orc(i int) with (appendonly=true,orientation=orc); # 在postgres数据库中创建ORC格式表

CREATE TABLE

 postgres=# create database dbnew template postgres;

 CREATE DATABASE

 postgres=#\c dbnew # 连接dbnew

可以看到,dbnew 中现在包含test 表

 dbnew=#\d

 List of relations

 Schema | Name | Type | Owner | Storage

 --------+------+-------+----------+-------------

 public | test | table | ChangLei | append only

 (1 row)

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

评论