Re: psql variable interpolation with subsequent underscore - Mailing list pgsql-general

From Bosco Rama
Subject Re: psql variable interpolation with subsequent underscore
Date
Msg-id 527D25EF.60609@boscorama.com
Whole thread Raw
In response to Re: psql variable interpolation with subsequent underscore  (Tim Kane <tim.kane@gmail.com>)
Responses Re: psql variable interpolation with subsequent underscore
List pgsql-general
On 11/08/13 09:30, Tim Kane wrote:
>
> Remi, to answer your question - this is being called as part of a shell
> script.

In that case your options expand greatly...

For example:
   tbl_name="YYYYMM"

   psql -c "alter table my_table rename to my_table_${tbl_name}_raw;"

or for more complex stuff:
   tbl_name="YYYYMM"

   psql -f- <<EOF
       alter table my_table rename to my_table_${tbl_name}_raw;
       ... <other DML/DDL>
   EOF

Or even:
   (
       <bunch of commands generating SQL DML/DDL>

   ) | psql -f-

Or ...

The sky's the limit once you remove the restriction of working 100%
*within* psql itself.

HTH

Bosco.


pgsql-general by date:

Previous
From: Tim Kane
Date:
Subject: Re: psql variable interpolation with subsequent underscore
Next
From: John R Pierce
Date:
Subject: Re: psql variable interpolation with subsequent underscore