简介
The World’s Most Advanced Open Source Relational Database. —— PostgreSQL
部署
Docker
…
示例,其中 /usr/local/nakadi4cbh/database/nakadi 路径包含了初始化 Nakadi 数据库脚本。
| 1 | docker run --name eventbus_pg -d \ | 
psql
- psql
- psql -U username- 1 
 2
 3
 4
 5- bash-4.2$ psql 
 psql (12.2)
 Type "help" for help.
 postgres=#- Getting information about databases
Command List
- \hHelp
- \lList databases
- \l+List databases with size, tablespace, and description
- \xExpand/narrow table lists
- \cConnect to a database
- \dtDisplay tables
- \dand \d+ Display columns (field names) of a table
- \duDisplay user roles
- \qquit
Command Usage
- \l数据库列表- 1 - postgres=# \l 
- \c连接数据库- 1 
 2
 3- postgres=# \c icosregistry_icos 
 You are now connected to database "icosregistry_icos" as user "postgres".
 icosregistry_icos=#- SQL
- Create Database & User, Grant 
| 1 | create database keycloak; | 
- Query Data From Table - 1 
 2
 3
 4
 5
 6- icosregistry_icos=# select * from asset_deploy; 
 asset_code | handler_type | opr_type | opr_status | opr_message | deploy_url | created
 ------------+--------------+----------+------------+-------------+------------+---------
 (0 rows)
 icosregistry_icos=#
pg_dump [OPTION]… [DBNAME]
Options
-s -s, –schema-only            dump only the schema, no data
-t -t, –table=PATTERN          dump the specified table(s) only
Examples
- 导出表结构示例
| 1 | pg_dump -s -t asset -t asset_group -t asset_group_membership -t asset_relationship -t asset_relationship_type -t asset_type -t asset_deploy icosregistry_icos | 
(待续)