From: | "michael(at)sqlexec(dot)com" <michael(at)sqlexec(dot)com> |
---|---|
To: | Eugene Yin <eugeneymail(at)ymail(dot)com> |
Cc: | "pgsql-sql(at)postgresql(dot)org" <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: public synonym |
Date: | 2016-01-07 20:27:13 |
Message-ID: | 568ECA21.20702@sqlexec.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
You can infer the context by first setting the search_path variable.
You can set it initially in your connection or do it for a database
context or even a role context
SET search_path = MASTER_USER, public, pg_catalog;
ALTER DATABASE whatever SET search_path = MASTER_USER, public, pg_catalog;
ALTER ROLE whoever SET search_path = MASTER_USER, public, pg_catalog;
Then you can continue to let the tables be non-qualified. bye bye
synonyms!
Regards
Michael
> Eugene Yin <mailto:eugeneymail(at)ymail(dot)com>
> Thursday, January 7, 2016 3:17 PM
> PostgreSQL ver 9.4.5. Linux OS.
> Application: Web Based
>
> Platform:
> App Server (java) --> jdbc call --> Database Server (PostgreSQL)
>
>
> I do know that PostgreSQL does not support the public synonym.Now, for
> a user schema (let's call it MASTER_USER), if I coded in the stored
> function/procedure like the following, without using a public synonym
> to identify the table name:
>
> select user_name from user_info_table
>
> then access it from the Java (web app) sidevia the JDBC call to the
> database, will that work?
>
> OR,
>
> I must use the identifier inside the sql, such as:
>
> select user_name fromMASTER_USER.user_info_table?
>
>
> I come from the Oracle world, there I first create the public synonym
> for the table, then in the stored procedure I just directly reference
> the table with no need to identify the table with a schema name. Like
> to know how it work under the PostgreSQL.
>
>
> Thanks
>
> Eugene
From | Date | Subject | |
---|---|---|---|
Next Message | Joe Conway | 2016-01-07 20:46:39 | Re: To get the column names, data types, and nullables of tables in the schema owned by MASTER_USER |
Previous Message | Eugene Yin | 2016-01-07 20:22:26 | To get the column names, data types, and nullables of tables in the schema owned by MASTER_USER |