Обсуждение: Creating db from sql script file

Поиск
Список
Период
Сортировка

Creating db from sql script file

От
"John Winn"
Дата:
I have worked with MSSql for awhile and one of the most convienent features of the Enterprise Manager is the "export
sqlto file" 
function. I am new to postgres and wondering if postgres supports this. The main reason is I use a dev. box and a live
box.If I make the changes on the dev box, can I export the sql and transfer it to the live box? Not to mention, when
thedatabase is created it would be nice to export the sql to have a hard copy. 

Is there an export/import sql feature? I have not been able to find it.

Thanks

Re: Creating db from sql script file

От
Danny Aldham
Дата:
>
> I have worked with MSSql for awhile and one of the most convienent features of the Enterprise Manager is the "export
sqlto file" 
> function. I am new to postgres and wondering if postgres supports this. The main reason is I use a dev. box and a
livebox. If I make the changes on the dev box, can I export the sql and transfer it to the live box? Not to mention,
whenthe database is created it would be nice to export the sql to have a hard copy. 
>
> Is there an export/import sql feature? I have not been able to find it.
>

Yep. To export a database use the pg_dump command, like:
/usr/local/pgsql/bin/pg_dump DB.Name > /tmp/DB.Name.sql
And then to import it, create your database and then use psql like:
/usr/local/pgsql/bin/psql DB.Name < /tmp/DB.Name.sql

-- Danny Aldham     Providing Certified Internetworking Solutions to Business
www.postino.com  E-Mail, Web Servers, Web Databases, SQL PHP & Perl

Re: Creating db from sql script file

От
Jason Earl
Дата:
Try pg_dump with the '-s' option.  That should give you what you need.
See man pg_dump for more information.

Jason

"John Winn" <JWinn@HuffTech.com> writes:

> I have worked with MSSql for awhile and one of the most convienent
> features of the Enterprise Manager is the "export sql to file"
> function. I am new to postgres and wondering if postgres supports
> this. The main reason is I use a dev. box and a live box. If I make
> the changes on the dev box, can I export the sql and transfer it to
> the live box? Not to mention, when the database is created it would be
> nice to export the sql to have a hard copy.
>
> Is there an export/import sql feature? I have not been able to find
> it.
>
> Thanks
>
> ---------------------------(end of
> broadcast)--------------------------- TIP 1: subscribe and unsubscribe
> commands go to majordomo@postgresql.org