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

2
  • This may answer your question: stackoverflow.com/questions/32271378/…. Commented May 23, 2021 at 12:14
  • @GordonLinoff I tried that answer and followed step 2,that's where i got this error Commented Jun 6, 2021 at 12:37

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.