PostgreSQL:修订间差异

来自Gea-Suan Lin's Wiki
跳到导航 跳到搜索
此页面具有访问限制。如果您看见此消息,则说明您没有权限访问此页面。
第12行: 第12行:


<syntaxhighlight lang="sql">
<syntaxhighlight lang="sql">
CREATE DATABASE exampledb;
CREATE DATABASE exampledb OWNER example;
CREATE USER exampleuser WITH ENCRYPTED PASSWORD 'password';
CREATE USER exampleuser WITH ENCRYPTED PASSWORD 'password';
GRANT ALL PRIVILEGES ON DATABASE exampledb TO exampleuser;
</syntaxhighlight>
</syntaxhighlight>



2021年6月23日 (三) 11:07的版本

PostgreSQL是一套RDBMS

安装

sudo sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'; wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -; sudo apt update; sudo apt install -y postgresql

常用指令

建立数据库与账号:

CREATE DATABASE exampledb OWNER example;
CREATE USER exampleuser WITH ENCRYPTED PASSWORD 'password';

管理

列出所有database_name下的schema,类似MySQL里的SHOW CREATE TABLE

pg_dump -d database_name -s -h hostname -U username

外部链接