Re: input from a file

Peter J. Schoenster <peter@schoenster.com>

From: "Peter J. Schoenster" <peter@schoenster.com>
To: pgsql-novice@postgresql.org
Date: 2001-05-04T00:50:28Z
Lists: 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."