forked from docs/doc-exports
Reviewed-by: Pruthi, Vineet <vineet.pruthi@t-systems.com> Co-authored-by: Lu, Huayi <luhuayi@huawei.com> Co-committed-by: Lu, Huayi <luhuayi@huawei.com>
17 lines
4.7 KiB
HTML
17 lines
4.7 KiB
HTML
<a name="EN-US_TOPIC_0000001188482226"></a><a name="EN-US_TOPIC_0000001188482226"></a>
|
|
|
|
<h1 class="topictitle1">Different Data Is Displayed for the Same Table Queried By Multiple Users</h1>
|
|
<div id="body8662426"><div class="section" id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_sf8a4063e06b44407b5553977911042c0"><h4 class="sectiontitle">Problem</h4><p id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_a020e907803924a94bcba5064208e6dc5">Two users log in to the same database human_resource and run the <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b84235270617825">select count(*) from areas</strong> statement separately to query the areas table, but obtain different results.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_s4074e59300254dd4a3368ea5359ed9b1"><h4 class="sectiontitle">Possible Causes</h4><p id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_a6a6164c741d547d1979f7bdcae6b5141">Check whether the two users really query the same table. In a relational database, a table is identified by three elements: <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b842352706103758">database</strong>, <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b84235270610381">schema</strong>, and <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b84235270610384">table</strong>. In this issue, <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b84235270610387">database</strong> is <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b842352706103818">human_resource</strong> and <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b1971353131103822">table</strong> is <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b842352706103829">areas</strong>. Then, check <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b699332483517">schema</strong>. Log in as users <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b1840473650103930"><span id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_text3365511124711">dbadmin</span></strong> and <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b1040633616103930">user01</strong> separately. It is found that <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b842352706104051">search_path</strong> is <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b84235270610418">public</strong> for <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b1481764093104022"><span id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_text3395436193513">dbadmin</span></strong> and <em id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_i842352697104034">$user</em> for <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b842352706104044">user01</strong>. By default, a schema having the same name as user <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b842352706164938"><span id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_text18279163012597">dbadmin</span></strong>, the cluster administrator, is not created. That is, all tables will be created in <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b1191696437104259">public</strong> if no schema is specified. However, when a common user, such as <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b19709847193512">user01</strong>, is created, the same-name schema (<strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b5714447193512">user01</strong>) is created by default. That is, all tables are created in <strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b177154471356">user01</strong> if the schema is not specified. In conclusion, both the two users are operating the table, causing that the same-name table is not really the same table.</p>
|
|
</div>
|
|
<div class="section" id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_sef5fe7e9180f4c69bc744de66d11555b"><h4 class="sectiontitle">Troubleshooting Method</h4><p id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_afd22f460cc954272bfeef7ab10e26fd9">Use <em id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_i842352697105257">schema</em><strong id="EN-US_TOPIC_0000001188482226__en-us_topic_0000001145826905_b84235270610535">.table</strong> to determine a table for query.</p>
|
|
</div>
|
|
</div>
|
|
<div>
|
|
<div class="familylinks">
|
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="dws_04_0491.html">SQL Execution Troubleshooting</a></div>
|
|
</div>
|
|
</div>
|
|
|