我正在嘗試使用如下 Sql 腳本在新資料庫中創建一個新資料庫和一個模式。資料庫是 PostgreSql 14.1
DROP DATABASE IF EXISTS DEZDAZ;
CREATE DATABASE DEZDAZ
WITH
OWNER = postgres
ENCODING = 'UTF8'
TABLESPACE = pg_default
CONNECTION LIMIT = -1;
\connect DEZDAZ;
CREATE SCHEMA DEZDAZ;
不斷出現以下錯誤:
DROP DATABASE
CREATE DATABASE
error: \connect: connection to server at "localhost" (::1), port 5432 failed: FATAL: database "DEZDAZ" does not exist
我遵循了以下答案: PostgreSQL:在特定資料庫中創建模式
謝謝你的幫助。
uj5u.com熱心網友回復:
嘗試:
\connect dezdaz.
您沒有這樣做,資料庫名稱按IdentifiersCREATE DATABASE "DEZDAZ"折疊為小寫。看起來正在做并且沒有找到名稱的大寫版本。這被稱為:dezdaz\connect"DEZDAZ"src/bin/psql/command.c
/*
* Read and interpret an argument to the \connect slash command.
...
/*
* Ideally we should treat the arguments as SQL identifiers. But for
* backwards compatibility with 7.2 and older pg_dump files, we have to
* take unquoted arguments verbatim (don't downcase them). For now,
* double-quoted arguments may be stripped of double quotes (as if SQL
* identifiers). By 7.4 or so, pg_dump files can be expected to
* double-quote all mixed-case \connect arguments, and then we can get rid
* of OT_SQLIDHACK.
*/
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/415492.html
標籤:
