1

Hi I am trying to load a .sql file into postgreSQL through postgreSQL command line. I tried this from postgreSQL command line

postgres-# psql -f 'D:\filmss.sql' -U postgres -d dbc1

dbc1 - The database i created, postgres - My username.

The tables are not created and the data is not loaded. I tried to run the code in .sql file line by line then it works fine until the COPY command

CREATE TABLE films (
    id integer NOT NULL,
    title character varying,
    release_year integer,
    country character varying,
    duration integer,
    language character varying,
    certification character varying,
    gross bigint,
    budget bigint
);

COPY films (id, title, release_year, country, duration, language, certification, gross, budget) FROM stdin;
1   Intolerance: Love's Struggle Throughout the Ages    1916    USA 123 \N  Not Rated   \N  385907
2   Over the Hill to the Poorhouse  1920    USA 110 \N  \N  3000000 100000
3   The Big Parade  1925    USA 151 \N  Not Rated   \N  245000
4   Metropolis  1927    Germany 145 German  Not Rated   26435   6000000
5   Pandora's Box   1929    Germany 110 German  Not Rated   9950    \N
\.

When i run the COPY command code(mentioned above) I get the following error.

ERROR:  invalid input syntax for type integer: "1   Intolerance: Love's Struggle Throughout the Ages    1916    USA 123 N  Not Rated   N  385907"
CONTEXT:  COPY films, line 1, column id: "1   Intolerance: Love's Struggle Throughout the Ages    1916    USA 123 N  Not Rated   N  385907"

Let me know how to import the file or these contents. Thanks in advance

mhimayath
  • 11
  • 1

0 Answers0