Re: Need Help in creating script

Поиск
Список
Период
Сортировка
От Oliver Elphick
Тема Re: Need Help in creating script
Дата
Msg-id 200105172205.f4HM5EAJ015058@linda.lfix.co.uk
обсуждение исходный текст
Ответ на Need Help in creating script  ("Prashant Sinha" <prashant@envivio.com>)
Список pgsql-admin
"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



В списке pgsql-admin по дате отправления:

Предыдущее
От: Didier Bretin
Дата:
Сообщение: process idle
Следующее
От: Alexander Dederer
Дата:
Сообщение: Re: Need Help in creating script