Обсуждение: psql "SCHEMA" switch

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

psql "SCHEMA" switch

От
Paul Silveira
Дата:
I was trying to run a psql script today against a database today.  This
script was schema agnostic.  (There were table creations and function
creations but none of them contained the specific schema to create them
in...)

I wanted to connect to a DB and then insert that new DDL into a "specific"
schema.  Because psql does not have a schema switch, I had to do it this
way...

sed -e '1i\\n SET search_path to contrib;\n' <
/usr/local/pgsql-8.2.0/share/contrib/tsearch2.sql | psql -dtemplate1 -p5433
-Upostgres

I would have liked to do it this way...
psql -dtemplate1 -p5433 -Upostgres -Xcontrib (I put an X there because "S"
was already taken.  It could be any letter...)

Anyone else agree?

-Paul



--
View this message in context: http://www.nabble.com/psql-%22SCHEMA%22-switch-tf2872570.html#a8028863
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


Re: psql "SCHEMA" switch

От
Michael Glaesemann
Дата:
On Dec 22, 2006, at 15:15 , Paul Silveira wrote:

> I wanted to connect to a DB and then insert that new DDL into a
> "specific"
> schema.  Because psql does not have a schema switch, I had to do it
> this
> way...

As the schema is part of the DDL, I think it's better to have it as
part of DDL script rather than a switch for psql, either as schema-
qualified tables in the script or using a SET search_path command in
the SQL script.

Michael Glaesemann
grzm seespotcode net



Re: psql "SCHEMA" switch

От
Tom Lane
Дата:
Michael Glaesemann <grzm@seespotcode.net> writes:
> On Dec 22, 2006, at 15:15 , Paul Silveira wrote:
>> Because psql does not have a schema switch, I had to do it this way...

> As the schema is part of the DDL, I think it's better to have it as
> part of DDL script rather than a switch for psql, either as schema-
> qualified tables in the script or using a SET search_path command in
> the SQL script.

Besides, you can get the effect already via PGOPTIONS:

PGOPTIONS="--search_path=myschema,yourschema" psql ...

            regards, tom lane

Re: psql "SCHEMA" switch

От
"Shoaib Mir"
Дата:
In your SQL script file you can add at the start something like this:

set search_path = contrib

and that should take care of it without this change in psql.

--------------------
Shoaib Mir
EnterpriseDB ( www.enterprisedb.com)

On 12/23/06, Paul Silveira <plabrh1@gmail.com > wrote:

I was trying to run a psql script today against a database today.  This
script was schema agnostic.  (There were table creations and function
creations but none of them contained the specific schema to create them
in...)

I wanted to connect to a DB and then insert that new DDL into a "specific"
schema.  Because psql does not have a schema switch, I had to do it this
way...

sed -e '1i\\n SET search_path to contrib;\n' <
/usr/local/pgsql-8.2.0/share/contrib/tsearch2.sql | psql -dtemplate1 -p5433
-Upostgres

I would have liked to do it this way...
psql -dtemplate1 -p5433 -Upostgres -Xcontrib (I put an X there because "S"
was already taken.  It could be any letter...)

Anyone else agree?

-Paul



--
View this message in context: http://www.nabble.com/psql-%22SCHEMA%22-switch-tf2872570.html#a8028863
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


---------------------------(end of broadcast)---------------------------
TIP 1: if posting/reading through Usenet, please send an appropriate
       subscribe-nomail command to majordomo@postgresql.org so that your
       message can get through to the mailing list cleanly