Thread: Schema Problem

From:
"Ashish Karalkar"
Date:

Hello All,
I am trying to create databse with script.
I run this script from root prompt with command
 
 
$ su - postgres -c 'path to script.sql'
 
 
In the script I follow following steps
 
 
1) create user xyz
2) create database xyz -O xyz
3) create schema xyz
4) {PG_PATH}/psql -d xyz -U xyz -f /usr/local/pgsql/QS/QS_100_2_Create_Table.sql -q -1
 
 
But still the tables are created in the public schema and not in xyz schema
 
 
Postgresql.conf entry:
serach path =' "$user",public'
 
tried with setting :
search path = ' xyz,"$user",public'
Same result
 
OR
search path = ' "$user",xyz,public'
Same result
 
OR
search path = ' "$user",xyz'
Error:no schema has been selected to create in
 
 
Please suggest me the corrective action.
 
Thanks In advance
 
Ashish...
From:
John DeSoi
Date:

On Jul 2, 2007, at 4:44 AM, Ashish Karalkar wrote:

> But still the tables are created in the public schema and not in
> xyz schema
>
>
> Postgresql.conf entry:
> serach path =' "$user",public'
>
> tried with setting :
> search path = ' xyz,"$user",public'
> Same result
>
> OR
> search path = ' "$user",xyz,public'
> Same result
>
> OR
> search path = ' "$user",xyz'
> Error:no schema has been selected to create in
>


I'd suggest that your search path command is not quite correct. You
should work that out in psql before trying it in a script. For example:

test=# set search_path to some_schema, "$user", public;
SET

test=# show search_path;
          search_path
------------------------------
some_schema, "$user", public
(1 row)

So here any new tables should now be created in "some_schema".




John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


From:
Tom Lane
Date:

"Ashish Karalkar" <> writes:
> In the script I follow following steps

> 1) create user xyz
> 2) create database xyz -O xyz
> 3) create schema xyz
> 4) {PG_PATH}/psql -d xyz -U xyz -f =
> /usr/local/pgsql/QS/QS_100_2_Create_Table.sql -q -1

Are you sure you are creating the schema in the right database?  Your
problems are consistent with the theory that schema xyz isn't present.

            regards, tom lane