Обсуждение: Need Help in creating script
Hi,
I am a new postgre user. I had used sql commands to create database and tables. Is it possible to create a script or installable version on existing database which I could run on any machine and it would crearte the database with all the tables and everything. Can anyone please help me with this?
Thanks in advance,
-Prashant.
"Prashant Sinha" wrote: >I am a new postgre user. I had used sql commands to create database and tab= >les. Is it possible to create a script or installable version on existing d= >atabase which I could run on any machine and it would crearte the database = >with all the tables and everything. Can anyone please help me with this? >Thanks in advance, A simple example: Put the database commands in a text file (precede comments with --): CREATE DATABASE junk; \connect junk -- Table "a" is adgaga axdfaxdfga hgfadsh CREATE TABLE a (f1 INT PRIMARY KEY, f2 TEXT); ...and so on... Then run the script: $ psql <sql.script (Obviously you need to be a database user with the privilege to let you do everything that is in the script.) (I see you are using Microsoft mail software. The above commands are for Unix; I don't know whether they need any modification for Windows.) -- Oliver Elphick Oliver.Elphick@lfix.co.uk Isle of Wight http://www.lfix.co.uk/oliver PGP: 1024R/32B8FAA1: 97 EA 1D 47 72 3F 28 47 6B 7E 39 CC 56 E4 C1 47 GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C ======================================== "Jesus said unto her, I am the resurrection, and the life. He that believeth in me, though he were dead, yet shall he live." John 11:25
Prashant Sinha wrote: > This is a multi-part message in MIME format. > > ------=_NextPart_000_0021_01C0DE12.BB861C80 > Content-Type: text/plain; charset="iso-8859-1" > Content-Transfer-Encoding: quoted-printable > > Hi, > I am a new postgre user. I had used sql commands to create database and > tab= les. Is it possible to create a script or installable version on > existing d= atabase which I could run on any machine and it would crearte > the database = with all the tables and everything. Can anyone please help > me with this? Thanks in advance, Look programm: pg_dump pg_dumpall psql
In article <9dutbv$2hdu$2@news.tht.net>, Alexander Dederer wrote: > Prashant Sinha wrote: > >> This is a multi-part message in MIME format. >> >> ------=_NextPart_000_0021_01C0DE12.BB861C80 >> Content-Type: text/plain; charset="iso-8859-1" >> Content-Transfer-Encoding: quoted-printable >> >> Hi, >> I am a new postgre user. I had used sql commands to create database and >> tab= les. Is it possible to create a script or installable version on >> existing d= atabase which I could run on any machine and it would crearte >> the database = with all the tables and everything. Can anyone please help >> me with this? Thanks in advance, > > Look programm: > pg_dump > pg_dumpall > psql > > Use pg_dump. pg_dump <database> > <file> createdb <newdatabase> cat <file> | psql <newdatabase> -- Manuel Cano Muñoz ------------------------------ SANYRES, S.A. Director Dpto. Sistemas manuel@sanyres.com manuel@sanyres.es