1、概述
一个OushuDB集群治理着多个数据库(database),每个数据库又蕴含多个模式(schema), 一个模式蕴含多个对象(表,视图,函数等),所以这些对象之间的层级构造为:
database -> schema -> (tables, functions, views)
每个模式,表,视图,函数等只属于一个database。本章次要介绍每一种对象的常见用法。具体应用语法能够参见参考手册。
2、数据库
OushuDB在初始化实现后,会默认生成三个数据库,能够应用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,当初OushuDB只反对以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)
发表回复