Quantcast
Channel: Question and Answer » postgresql
Viewing all articles
Browse latest Browse all 1138

ERROR: relation “name” does not exist

$
0
0

I am trying to import a postgresql database table sent to me in phpPgAdmin, I am following the instruction from this import database

But after doing so, several error appear, I also tried to import the database using cmd but the same error continues to persist

DROP TABLE
postgresql.sql:33: ERROR: relation "accessories_id_seq" does not exist
postgresql.sql:34: ERROR: relation "public.accessories" does not exist
BEGIN
postgresql.sql:40: ERROR: relation "public.accessories" does not exist
LINE 1: INSERT INTO "public"."accessories" VALUES ('1', 'Vario V8', ...
^
postgresql.sql:41: ERROR: current transaction is aborted, commands ignored until end of transaction block

I researched the problem here in stackoverflow but people who had the same error are making new database tables and and thus most of the errors comes from mixed-case spelling, I’m just pulling data from a database sent to me.
Any answers would be greatly appreciated.

In cmd I used this command

"%PROGRAMFILES%/Postgresql/9.3/bin/psql.exe" -v ON_ERROR_STOP=1 -U postgres -d postgres -a -f C:/Sites/xmastool/postgresql.sql 

The file is an SQL file

After removing all the drop statements this error now appears

postgresql.sql:33: ERROR: syntax error at or near ""
LINE 1: /*
^
postgresql.sql:34: ERROR: relation "public.accessories" does not exist
BEGIN
postgresql.sql:40: ERROR: relation "public.accessories" does not exist
LINE 1: INSERT INTO "public"."accessories" VALUES ('1', 'Vario V8', ...
^

This is the first lines of the code

/*
 Navicat Premium Data Transfer

 Source Server         : 
 Source Server Type    : PostgreSQL
 Source Server Version : 90207
 Source Host           : 
 Source Database       : foo
 Source Schema         : public

 Target Server Type    : PostgreSQL
 Target Server Version : 90207
 File Encoding         : utf-8

 Date: 11/19/2014 15:42:40 PM
*/

-- ----------------------------
--  Table structure for accessories
-- ----------------------------

CREATE TABLE "public"."accessories" (
    "id" int4 NOT NULL DEFAULT nextval('accessories_id_seq'::regclass),
    "accessory_name" varchar(255) DEFAULT ''::character varying COLLATE "default",
    "accessory_description" text COLLATE "default",
    "accessory_size" varchar(255) DEFAULT ''::character varying COLLATE "default",
    "created_at" timestamp(6) NULL,
    "updated_at" timestamp(6) NULL,
    "price" varchar(255) DEFAULT '0.00'::character varying COLLATE "default",
    "active" int4 DEFAULT 1,
    "img_url" varchar(255) DEFAULT ''::character varying COLLATE "default"
)
WITH (OIDS=FALSE);
ALTER TABLE "public"."accessories" OWNER TO "gptpgsxlzwywhc";

-- ----------------------------
--  Records of accessories
-- ----------------------------
BEGIN;
INSERT INTO "public"."accessories" VALUES ('');

Viewing all articles
Browse latest Browse all 1138

Latest Images

Trending Articles



Latest Images