Search Postgresql Archives

Re: psql variable interpolation with subsequent underscore

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.


-- 
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux