简体   繁体   中英

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. 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

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 (

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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