关于oushudb-hawq:OushuDB-产品介绍基本用法概述

8次阅读

共计 1164 个字符,预计需要花费 3 分钟才能阅读完成。

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)
正文完
 0