简体   繁体   English

PostgreSQL SQL导入失败,错误,因为找不到架构

[英]PostgreSQL SQL import fails with error as schema not found

I am trying to import an SQL file as part of the database through PGAdmin3 but I am getting error as the schema not found. 我正在尝试通过PGAdmin3将SQL文件作为数据库的一部分导入,但是由于找不到架构,因此出现错误。 But when I try to select the namespace it list that schema. 但是,当我尝试选择名称空间时,它将列出该架构。
Below is the output from the DB 下面是数据库的输出

test=# select nspname from pg_catalog.pg_namespace;
      nspname
--------------------
 pg_catalog
 pg_toast
 public
 pg_temp_1
 pg_toast_temp_1
 information_schema
 testschema
(7 rows)

Below is the sql commands which I am trying to run from script 以下是我尝试从脚本运行的sql命令

CREATE TABLE TestSchema.Emp (
                lastname VARCHAR(50) NOT NULL,
                firstname VARCHAR(10) NOT NULL,
                empid INTEGER PRIMARY KEY
};

ERROR:  schema "testschema" does not exist
********** Error **********

ERROR: schema "testschema" does not exist
SQL state: 3F000

Any thoughts why this error is coming. 任何想法为什么会出现此错误。

You have a typo: 您有错字:

CREATE TABLE TestSchema.Emp (
                lastname VARCHAR(50) NOT NULL,
                firstname VARCHAR(10) NOT NULL,
                empid INTEGER PRIMARY KEY
}; -- Put ) instead of } 

Normally it does not work 通常它不起作用

Try to replace: 尝试更换:

CREATE TABLE TestSchema.Emp (

By 通过

CREATE TABLE testschema.Emp (

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM