Skip site navigation (1) Skip section navigation (2)

Re: input from a file

From: "Peter J(dot) Schoenster" <peter(at)schoenster(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: input from a file
Date: 2001-05-04 00:50:28
Message-ID: 3AF1A874.2551.7226A83@localhost (view raw or flat)
Thread:
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."

In response to

pgsql-novice by date

Next:From: Andrew McMillanDate: 2001-05-04 08:07:44
Subject: Re: [NOVICE] Re: psql with PHP question
Previous:From: Justin SeiferthDate: 2001-05-03 21:53:35
Subject: VARCHAR references

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group