在PostgreSQL数据库中,每个表格table都有一个owner,这个owner拥有修改table里字段的个数、名称、类型等权限。这里以teachdb数据库中student表格的owner设置hello为例,进行说明,将owner:postgres --> hello。

1、创建teachdb数据库

    使用Navicat连接PostgreSQL,创建一个名称为teachdb的数据库,如图(1)所示:

图(1) 创建teachdb数据库

2、设置表格的owner

    将student表格的owner,由postgres改为hello,命令如下:

## 1)使用postgres登录teachdb
psql -U postgres -d teachdb

## 2)查看owner
\d

## 3)设置student的owner为hello
alter table student owner to hello;

## 4)查看更新后的owner
\d
图(2) 设置student表格的owner为hello

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐