作者:瀚高PG实验室 (Highgo PG Lab)- 波罗
HGDB创建数据库对象与变量search_path的值有关,当创建对象时,如果未指定模式,这些对象将会在默认的模式下被创建,这个模式叫pubulic。一个例外情况是另一个模式首先出现在search_path。以下问题是在search_path默认值发生变化是抛出的,请参考如下:
su - highgo
psql
highgo=# \c testdb
PSQL: Release 4.1.1
Connected to:
HighGo Database V4.1 Enterprise Edition Release 4.1.1 - 64-bit Production
You are now connected to database "testdb" as user "user_t".
testdb=# CREATE TABLE test(id integer not null);
ERROR: 3F000: no schema has been selected to create in
LINE 1: CREATE TABLE test(id integer not null);
^
创建表出现异常,按照一般理解表会创建到默认的模式public下,结果这里报错了,提示创建表没有模式可选。
testdb=# create schema schema_t;
CREATE SCHEMA
testdb=# \dn
List of schemas
Name | Owner
----------------+--------
hgdb_catalog | highgo
oracle_catalog | highgo
public | highgo
schema_t | user_t
(4 rows)
testdb=# CREATE TABLE test(id integer not null); --不指定模式创建表对象
CREATE TABLE
testdb=# \d
List of relations
Schema | Name | Type | Owner
----------------+------+-------+--------
oracle_catalog | dual | view | highgo
schema_t | test | table | user_t
(2 rows)
testdb=# \dn
List of schemas
Name | Owner
----------------+--------
hgdb_catalog | highgo
oracle_catalog | highgo
public | highgo
schema_t | user_t
(4 rows)
testdb=# select user;
current_user
--------------
user_t
(1 row)
testdb=# show search_path;
search_path
-------------
schema_t
(1 row)
结论:经过以上调试,最终发现是之前的测试中将serch_path的值修改成schema_t,而且在数据库中这个模式被删除了,结果出现创建数据库对象找不到模式的提示信息。
本文探讨了在HighGo Database (HGDB)中创建数据库对象时遇到的问题,特别是在search_path设置不当导致无法创建表的情况。通过调整search_path的值并明确指定模式,成功解决了创建表时找不到模式的问题。
1420

被折叠的 条评论
为什么被折叠?



