Re: input from a file - Mailing list pgsql-novice

From Peter J. Schoenster
Subject Re: input from a file
Date
Msg-id 3AF1A874.2551.7226A83@localhost
Whole thread Raw
In response to input from a file  ("Stephen M. Ford" <sford@Eng.Auburn.EDU>)
List pgsql-novice
> I have a dump from a msql database into a file and would like postgre
> to build the tables and insert the data into those tables.  How do I
> go about getting postgre to read commands from a file?

Here is a simple example (the following is in a file I would call
career_positions.psql) :

CREATE TABLE "career_positions" (
"cpid" smallint,
"f_ecid" smallint REFERENCES employment_categories (ecid),
"career_positions_name" character varying(60),
"orderby" smallint
);

COPY "career_positions"  FROM stdin;
32    8    Accountant and Auditor    32
33    8    Advertising/Marketing    33
596    20    Writers and Authors     596
\.

create index cpid_index on career_positions (cpid);
create index cp_name_index on career_positions
(career_positions_name);

_end file

and then just

psql database < career_positions.psql


Peter
datapanik  - Toronto Canada
"The user interface should be a clear and simple path through
information and tasks, not a series of gates and doors."

pgsql-novice by date:

Previous
From: Patrice Espié
Date:
Subject: Re: SELECT performance problem on a join
Next
From: Knut Suebert
Date:
Subject: unique (a,b)?