1. postgresql常用命令
进入数据库postgres
:
$ psql postgres
psql (11.2)
Type "help" for help.
postgres=#
退出postgresql shell:
postgres=# exit
创建用户olddriver
:
postgres=# create user olddriver with password '123456';
CREATE ROLE
删除用户oldriver
, 并创建用户olddriver
, 将数据库的拥有者修改为olddriver
:
postgres=# drop role oldriver;
ERROR: role "oldriver" cannot be dropped because some objects depend on it
DETAIL: privileges for database postgres
postgres=# revoke all on database didi from oldriver;
REVOKE
postgres=# drop role oldriver;
ERROR: role "oldriver" cannot be dropped because some objects depend on it
DETAIL: owner of database didi
postgres=# create user olddriver with password '123456';
CREATE ROLE
postgres=# alter database didi owner to olddriver;
ALTER DATABASE
postgres=# drop role oldriver;
DROP ROLE
postgres=#
创建数据库didi
:
postgres=# create database didi owner olddriver;
CREATE DATABASE
修改数据库didi
的拥有者为dicar
:
postgres=# alter database didi owner to dicar;
ALTER DATABASE