Thread: Batch Definitions - Need Help

Batch Definitions - Need Help

From
"Michael Avila"
Date:
I've searched the manual that came with PostgreSQL 8.0.1 (I have the one
page html version and I used the browser find on page) and could not find
anything on how to create tables and insert data into a database. This is my
first time using PostgreSQL (I have used MySQL quite a bit) so I am not sure
where else to look or what else to do. Surely this must be possible so I
figure I am missing something somewhere.

Any help is greatly appreciated. Point me to someplace in the manual and I
will read it. Or provide examples.  Either way, the help is greatly
appreciated.

Mike


--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.7.0 - Release Date: 6/13/2005


Attachment

Re: Batch Definitions - Need Help

From
Keith Worthington
Date:
Michael Avila wrote:
> I've searched the manual that came with PostgreSQL 8.0.1 (I have the one
> page html version and I used the browser find on page) and could not find
> anything on how to create tables and insert data into a database. This is my
> first time using PostgreSQL (I have used MySQL quite a bit) so I am not sure
> where else to look or what else to do. Surely this must be possible so I
> figure I am missing something somewhere.
>
> Any help is greatly appreciated. Point me to someplace in the manual and I
> will read it. Or provide examples.  Either way, the help is greatly
> appreciated.
>
> Mike

Mike,

I suggest you use the online documentation.  If you already know SQL
then just try what you know how to do and see what happens.  The
developers have created a database that is hugely SQL standard.  I
realize there could be some argument about that point but if you already
know compliant sql why look for issues.

Try these documentation pages.
http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html
http://www.postgresql.org/docs/8.0/interactive/sql-insert.html
http://www.postgresql.org/docs/8.0/interactive/sql-copy.html

--
Kind Regards,
Keith

Re: Batch Definitions - Need Help

From
Tom Lane
Date:
"Michael Avila" <mavila@mich.com> writes:
> I've searched the manual that came with PostgreSQL 8.0.1 (I have the one
> page html version and I used the browser find on page) and could not find
> anything on how to create tables and insert data into a database.

Try the tutorial:
http://www.postgresql.org/docs/8.0/static/tutorial.html

> This is my first time using PostgreSQL (I have used MySQL quite a bit)

It's not *all* that much different from MySQL --- SQL is an allegedly
standardized language, after all.

            regards, tom lane

Re: Batch Definitions - Need Help

From
"Michael Avila"
Date:
Oppps! I forgot only one word in my description - BATCH. Apologies. Makes a
BIG difference.

I want to load table definitions and insert data from a batch file. The
batch file was created from a MySQL database so I know I will have to make
some changes. But I want to load it into PostgreSQL and have others who use
this table be able to do the same thing.

Again, Apologies for the miscommunication.

Mike



-----Original Message-----
From: Keith Worthington [mailto:KeithW@NarrowPathInc.com]
Sent: Monday, June 13, 2005 7:23 PM
To: Michael Avila
Cc: Pgsql-Novice
Subject: Re: [NOVICE] Batch Definitions - Need Help


Michael Avila wrote:
> I've searched the manual that came with PostgreSQL 8.0.1 (I have the one
> page html version and I used the browser find on page) and could not find
> anything on how to create tables and insert data into a database. This is
my
> first time using PostgreSQL (I have used MySQL quite a bit) so I am not
sure
> where else to look or what else to do. Surely this must be possible so I
> figure I am missing something somewhere.
>
> Any help is greatly appreciated. Point me to someplace in the manual and I
> will read it. Or provide examples.  Either way, the help is greatly
> appreciated.
>
> Mike

Mike,

I suggest you use the online documentation.  If you already know SQL
then just try what you know how to do and see what happens.  The
developers have created a database that is hugely SQL standard.  I
realize there could be some argument about that point but if you already
know compliant sql why look for issues.

Try these documentation pages.
http://www.postgresql.org/docs/8.0/interactive/sql-createtable.html
http://www.postgresql.org/docs/8.0/interactive/sql-insert.html
http://www.postgresql.org/docs/8.0/interactive/sql-copy.html

--
Kind Regards,
Keith
--
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.7.0 - Release Date: 6/13/2005

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.7.0 - Release Date: 6/13/2005


Re: Batch Definitions - Need Help

From
Tom Lane
Date:
"Michael Avila" <mavila@mich.com> writes:
> Oppps! I forgot only one word in my description - BATCH. Apologies. Makes a
> BIG difference.

> I want to load table definitions and insert data from a batch file. The
> batch file was created from a MySQL database so I know I will have to make
> some changes.

Either
psql mydb <batchfile
or
psql -f batchfile mydb

... edit out MySQL-isms, lather rinse repeat ...

I don't know exactly what a MySQL batch file looks like, in particular
whether they do anything nonstandard for bulk data load.  To the extent
that the file contains reasonably-standard SQL commands, though, it
should work.

            regards, tom lane

Re: Batch Definitions - Need Help

From
John DeSoi
Date:
On Jun 13, 2005, at 8:45 PM, Tom Lane wrote:

> Either
> psql mydb <batchfile
> or
> psql -f batchfile mydb
>
> ... edit out MySQL-isms, lather rinse repeat ...
>
> I don't know exactly what a MySQL batch file looks like, in particular
> whether they do anything nonstandard for bulk data load.  To the extent
> that the file contains reasonably-standard SQL commands, though, it
> should work.


To start you will need to replace any single line comments that start
with '#' to use the SQL standard '--'

You might find some helpful tools here to perform some of the
conversion task:

http://sqlfairy.sourceforge.net/



John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL