定义数据库对象
创建与管理数据库
通过\h命令查看创建数据库的语法,如下所示:
testdw-# \h create database Command: CREATE DATABASE Description: create a new database Syntax: CREATE DATABASE name [ [ WITH ] [ OWNER [=] dbowner ] [ TEMPLATE [=] template ] [ ENCODING [=] encoding ] [ LC_COLLATE [=] lc_collate ] [ LC_CTYPE [=] lc_ctype ] [ TABLESPACE [=] tablespace ] [ CONNECTION LIMIT [=] connlimit ] ] 连接限制 |
说明:
- 一个GPDB系统可以有多个数据库;
- 关于数据库模版:可以基于模版创建数据库,缺省数据库模版为template1,GP系统内部使用模板:template0和postgres;
- 创建数据库应该具备CREATEDB权限或者SUPERUSER身份;
- 通过CREATEDATABASE 命令创建;
template1=# create database devdw; CREATE DATABASE |
- 克隆一个数据库
template1=#\c devdw 使用\c连接数据库 You are now connected to database "devdw" as user "gpadmin". devdw=# create table tab_01(id int); 创建表 NOTICE: Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Database data distribution key for this table. HINT: The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen are th |