From: | Cédric Villemain <cedric(dot)villemain(dot)debian(at)gmail(dot)com> |
---|---|
To: | salah jubeh <s_jubeh(at)yahoo(dot)com> |
Cc: | "andreas(at)a-kretschmer(dot)de" <andreas(at)a-kretschmer(dot)de>, pgsql <pgsql-general(at)postgresql(dot)org> |
Subject: | Re: many sql file and one transaction |
Date: | 2011-10-18 12:57:58 |
Message-ID: | CAF6yO=298t-K7ki=M8UgZajTu995fDOiWZigGXOfk9rhE3n2OQ@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
2011/10/18 salah jubeh <s_jubeh(at)yahoo(dot)com>:
> Hello,
> Thanks for the reply.
> I considered cat as an option but I did not go for it, because of the
> number of sql files I have is large which makes the code not readable
> The second thing, which is more important is because I have some advantages
> with using -f such as the line number which causing the error.
you can do :
cat module1.sql \
module2.sql \
module_etc.sql \
| psql -f -
> Regards
>
>
>
>
>
> ________________________________
> From: "andreas(at)a-kretschmer(dot)de" <andreas(at)a-kretschmer(dot)de>
> To: salah jubeh <s_jubeh(at)yahoo(dot)com>
> Sent: Tuesday, October 18, 2011 2:23 PM
> Subject: Re: [GENERAL] many sql file and one transaction
>
>
> Zitat von salah jubeh <s_jubeh(at)yahoo(dot)com>:
>
>> Hello,
>>
>>
>> I have many SQL script files to update schema, delete data, unit
>> test ....etc. I want to run all the files in one transaction using
>> shell script to ease the installation procedure. I can do that from
>> the psql client by using the \i option
>>
>>
>> BEGIN;
>>
>> \i / .../ module1.sql
>>
>> \i / .../ module2.sql
>>
>> \i / .../ module_etc.sql
>> COMMIT;
>>
>>
>> Is there a way to do that using psql command shell script.
>>
>>
>> I.E.
>>
>> I want to run the following in one transaction,
>>
>> psql -f module1.sql
>>
>> psql -f module2.sql
>>
>> psql -f module_etc.sql
>
>
> cat module1.sql module2.sql module_etc.sql | psql
>
>
> Regards, Andreas
>
>
>
>
--
Cédric Villemain +33 (0)6 20 30 22 52
http://2ndQuadrant.fr/
PostgreSQL: Support 24x7 - Développement, Expertise et Formation
From | Date | Subject | |
---|---|---|---|
Next Message | Merlin Moncure | 2011-10-18 13:23:07 | Re: many sql file and one transaction |
Previous Message | salah jubeh | 2011-10-18 12:40:07 | Re: many sql file and one transaction |