时间:2021-07-01 10:21:17 帮助过:43人阅读
school=# select * from schema_test.tbl_test ; a --- (0 rows) school=# select * from schema_test.view_test ; a --- (0 rows)
语法:
school=# \h alter schema
Command: ALTER SCHEMA
Description: change the definition of a schema
Syntax:
ALTER SCHEMA name RENAME TO new_name
ALTER SCHEMA name OWNER TO new_owner
参数:
name
模式名称
new_name
模式新的名称,同样新名称也不能以pg_开头
new_owner
模式新用户名称
示例
school=# alter schema schema_test owner to postgres ; ALTER SCHEMA school=# alter schema schema_test rename to test; ALTER SCHEMA school=# \dn+ List of schemas Name | Owner | Access privileges | Description --------+----------+----------------------+------------------------ public | postgres | postgres=UC/postgres+| standard public schema | | =UC/postgres | test | postgres | | (2 rows)
语法:
school=# \h drop schema
Command: DROP SCHEMA
Description: remove a schema
Syntax:
DROP SCHEMA [ IF EXISTS ] name [, ...] [ CASCADE | RESTRICT ]
参数:
IF EXISTS
如果模式不存在,不会抛出错误。
name
模式名称。
CASCADE
自动删除该模式下数据库对象。
RESTRICT
如果该模式下还存在数据库对象,则不允许删除该模式,RESTRICT为缺省值。
示例:
school=# drop schema test; ERROR: cannot drop schema test because other objects depend on it DETAIL: table test.tbl_test depends on schema test view test.view_test depends on schema test HINT: Use DROP ... CASCADE to drop the dependent objects too.
school=# drop schema test cascade; NOTICE: drop cascades to 2 other objects DETAIL: drop cascades to table test.tbl_test drop cascades to view test.view_test DROP SCHEMA
postgresql模式创建、修改、删除
标签:table asc 操作 l数据库 standard 图片 相同 rename bec