From: | Marek Pętlicki <marpet(at)buy(dot)pl> |
---|---|
To: | "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: how to load a sql-file???? |
Date: | 2001-03-29 12:14:13 |
Message-ID: | 20010329141413.A2879@marek.almaran.home |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Wednesday, March, 2001-03-28 at 16:55:55, will trillich wrote:
> On Thu, Mar 29, 2001 at 12:17:31AM +0200, Marek Pętlicki wrote:
> > On Tuesday, March, 2001-03-27 at 21:42:39, markus jais wrote:
> > >
> > > in MySQL I can type something like in Bash on my linux box:
> > >
> > > $ mysql -u root -p < file.sql
> > >
> > > then the file file.sql is read.
> > >
> > > can you tell me how to do this with postgresql???
> > > thanks a lot.
> >
> > very similar:
> >
> > psql dbname username < file.sql
> >
> > should work
> >
> > (you can well omit username if it is the same as your login name)
>
> if your sql is flawless, go right ahead.
>
> since psql reads "<file" from its STDIN, it won't include any
> line numbers to help you track down troubles. (as far as it's
> concerned, you're just typing reeeeal fast, so the feedback would
> occur right as you type, so line numbers would be superfluous.)
>
> on the other hand, both
>
> psql -f file-containing-sql mydb
>
> and
>
> psql mydb
> mydb=> \i file-containing-sql
>
> will spit out error messages including line numbers to help you
> debug your sql.
off course, but note that the question was if one could use '< file.sql'
It is the same mechanism as issuing:
my_program_creating_sql | psql dbname username
(for example to use compressed dump to restore without decompressing it
to the disk first) which can't be done with -f option ;-)
Nevertheless your remark about debugging errors in sql files is very
important...
regards
--
Marek Pętlicki <marpet(at)buy(dot)pl>
From | Date | Subject | |
---|---|---|---|
Next Message | Russell Hires | 2001-03-29 12:50:21 | Re: Determine Time in other Time Zone |
Previous Message | Eric Frazier | 2001-03-29 10:14:32 | Re: [JDBC] Logging Queries |