PostgreSQL更改表格的owner

Posted sanqima

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了PostgreSQL更改表格的owner相关的知识,希望对你有一定的参考价值。

    在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

以上是关于PostgreSQL更改表格的owner的主要内容,如果未能解决你的问题,请参考以下文章