public synonym - Mailing list pgsql-sql
From | Eugene Yin |
---|---|
Subject | public synonym |
Date | |
Msg-id | 358282890.1765953.1452197860946.JavaMail.yahoo@mail.yahoo.com Whole thread Raw |
Responses |
Re: public synonym
|
List | pgsql-sql |
<div style="color:#000; background-color:#fff; font-family:HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande,sans-serif;font-size:13px"><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" id="yui_3_16_0_1_1452135740077_60638"style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);">PostgreSQL ver 9.4.5. Linux OS.</span></div><divdir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" style="font-family: Consolas, 'LucidaConsole', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);">Application: Web Based</span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" style="font-family:Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color:rgb(240, 247, 255);"><br /></span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class=""id="yui_3_16_0_1_1452135740077_61042" style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);">Platform: </span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><spanclass="" id="yui_3_16_0_1_1452135740077_61044" style="font-family: Consolas, 'LucidaConsole', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"> AppServer (java) --> jdbc call --> Database Server (PostgreSQL)</span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><spanclass="" style="font-family: Consolas, 'Lucida Console', monospace; font-size:12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"><br /></span></div><div dir="ltr"id="yui_3_16_0_1_1452135740077_60559"><span class="" style="font-family: Consolas, 'Lucida Console', monospace;font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"><br /></span></div><divdir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" id="yui_3_16_0_1_1452135740077_60642" style="font-family:Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color:rgb(240, 247, 255);">I do know that <span class="" id="yui_3_16_0_1_1452135740077_60687" style="font-size:12.8000001907349px;">PostgreSQL</span> does not support the public synonym.</span><span class="" id="yui_3_16_0_1_1452135740077_60644"style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);"> </span><span class="" id="yui_3_16_0_1_1452135740077_60646"style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);">Now, for a user schema (let's call it MASTER_USER),if I coded in the stored function/procedure like the following, </span><span class="" id="yui_3_16_0_1_1452135740077_60794"style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);">without using a public synonym to identify the </span><spanclass="" id="yui_3_16_0_1_1452135740077_60752" style="font-family: Consolas, 'Lucida Console', monospace;font-size: 12.8000001907349px; text-indent: -7px;">table name</span><span class="" id="yui_3_16_0_1_1452135740077_60797"style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);">: </span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><spanclass="" style="font-family: Consolas, 'Lucida Console', monospace; font-size:12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"><br /></span></div><div dir="ltr"id="yui_3_16_0_1_1452135740077_60559"><span class="" id="yui_3_16_0_1_1452135740077_60746" style="font-family: Consolas,'Lucida Console', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);">selectuser_name from </span><span class="" id="yui_3_16_0_1_1452135740077_60836" style="font-family: Consolas, 'LucidaConsole', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);">user_info_table</span></div><divdir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" style="font-family:Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color:rgb(240, 247, 255);"><br /></span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class=""id="yui_3_16_0_1_1452135740077_60750" style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);">then access it from the Java (web app) side</span><spanclass="" id="yui_3_16_0_1_1452135740077_60648" style="font-family: Consolas, 'Lucida Console', monospace;font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"> </span><span class=""id="yui_3_16_0_1_1452135740077_60650" style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);">via the JDBC call to the database, will that work?</span><spanclass="" id="yui_3_16_0_1_1452135740077_60652" style="font-family: Consolas, 'Lucida Console', monospace;font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"> </span></div><div dir="ltr"id="yui_3_16_0_1_1452135740077_60559"><span class="" style="font-family: Consolas, 'Lucida Console', monospace;font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"><br /></span></div><divdir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" id="yui_3_16_0_1_1452135740077_60654" style="font-family:Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color:rgb(240, 247, 255);">OR, </span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class=""style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color:rgb(240, 247, 255);"><br /></span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class=""id="yui_3_16_0_1_1452135740077_60801" style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);">I must use the identifier inside the sql, suchas:</span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" style="font-family: Consolas, 'LucidaConsole', monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"><br/></span></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" id="yui_3_16_0_1_1452135740077_60769"style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);"> select <span class="" id="yui_3_16_0_1_1452135740077_60875"style="font-size: 12.8000001907349px;">user_name</span> from</span><span class="" id="yui_3_16_0_1_1452135740077_60656"style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);"> </span><span class="" id="yui_3_16_0_1_1452135740077_60658"style="font-family: Consolas, 'Lucida Console', monospace; font-size: 12.8000001907349px;text-indent: -7px; background-color: rgb(240, 247, 255);"><span class="" id="yui_3_16_0_1_1452135740077_60863"style="font-size: 12.8000001907349px;">MASTER_USER</span>.<span class="" id="yui_3_16_0_1_1452135740077_60882"style="font-size: 12.8000001907349px;">user_info_table</span>?</span><br /></div><divdir="ltr" id="yui_3_16_0_1_1452135740077_60559"><span class="" style="font-family: Consolas, 'Lucida Console',monospace; font-size: 12.8000001907349px; text-indent: -7px; background-color: rgb(240, 247, 255);"><br /></span></div><divdir="ltr" id="yui_3_16_0_1_1452135740077_60559"><br /></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559">Icome 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.</div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><br /></div><divdir="ltr" id="yui_3_16_0_1_1452135740077_60559"> </div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"><brid="yui_3_16_0_1_1452135740077_60985" /></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"style="text-indent: -7px;"><font face="Consolas, Lucida Console, monospace"><span style="font-size:12.8000001907349px; background-color: rgb(240, 247, 255);">Thanks</span></font></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"style="text-indent: -7px;"><font face="Consolas, Lucida Console, monospace"><span style="font-size:12.8000001907349px; background-color: rgb(240, 247, 255);"><br /></span></font></div><div dir="ltr" id="yui_3_16_0_1_1452135740077_60559"style="text-indent: -7px;"><font face="Consolas, Lucida Console, monospace"><span style="font-size:12.8000001907349px; background-color: rgb(240, 247, 255);">Eugene</span></font></div></div>