{"id":8403,"date":"2016-06-21T12:13:25","date_gmt":"2016-06-21T10:13:25","guid":{"rendered":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/"},"modified":"2016-06-21T12:13:25","modified_gmt":"2016-06-21T10:13:25","slug":"ora-01775-looping-chain-of-synonyms","status":"publish","type":"post","link":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/","title":{"rendered":"ORA-01775: looping chain of synonyms"},"content":{"rendered":"<h2>By Franck Pachot<\/h2>\n<p>.<br \/>\nThis error message is misleading. You may encounter it when you expect ORA-00942: table or view does not exist. Let&#8217;s explain<br \/>\n<!--more--><br \/>\nI&#8217;m connected as SCOTT and create a PUBLIC SYNONYM for an object that do not exists:<\/p>\n<pre><code>\nSQL&gt; create public synonym MONEY for NOTHING;\nSynonym created.\n<\/code><\/pre>\n<p>No error message.<br \/>\nOnly when I read it I have an error message telling me that there are no table or view behind it:<\/p>\n<pre><code>\nSQL&gt; select * from NOTHING;\nselect * from NOTHING\n              *\nERROR at line 1:\nORA-00942: table or view does not exist\n<\/code><\/pre>\n<p>Let&#8217;s do the same but call it BONUS instead of MONEY:<\/p>\n<pre><code>\nSQL&gt; create public synonym BONUS for NOTHING;\nSynonym created.\n&nbsp;\nSQL&gt; select * from BONUS;\nno rows selected\n<\/code><\/pre>\n<p>No error here. Why? because I&#8217;ve a table that is called BONUS. So the name is resolved with the table and the synonym is not even tried.<\/p>\n<p>I&#8217;ll now drop that synonym and create it for the table BONUS. Same name for the public synonym and for the table.<\/p>\n<pre><code>\nSQL&gt; drop public synonym BONUS;\nSynonym dropped.\n&nbsp;\nSQL&gt; create public synonym BONUS for BONUS;\nSynonym created.\n<\/code><\/pre>\n<p>As user SCOTT, when I query BONUS the name is resolved as the table:<\/p>\n<pre><code>\nSQL&gt; show user\nUSER is \"SCOTT\"\nSQL&gt; select * from BONUS;\nno rows selected\n<\/code><\/pre>\n<p>As another user, when I query BONUS the name is resolved as the synonym, which finally reads SCOTT.BONUS:<\/p>\n<pre><code>\nSQL&gt; show user\nUSER is \"SCOTT\"\nSQL&gt; select * from BONUS;\nno rows selected\n<\/code><\/pre>\n<p>In 12c it is easy to see the final query:<\/p>\n<pre><code>\nSQL&gt; variable c clob\nSQL&gt; exec dbms_utility.expand_sql_text('select * from BONUS',:c);\nPL\/SQL procedure successfully completed.\n&nbsp;\nSQL&gt; print c\n&nbsp;\nC\n----------------------------------------------------------------------------------------------------------\nSELECT \"A1\".\"ENAME\" \"ENAME\",\"A1\".\"JOB\" \"JOB\",\"A1\".\"SAL\" \"SAL\",\"A1\".\"COMM\" \"COMM\" FROM \"SCOTT\".\"BONUS\" \"A1\"\n<\/code><\/pre>\n<p>But now, what happens when we drop the table?<\/p>\n<pre><code>\nSQL&gt; drop table SCOTT.BONUS;\nTable dropped.\n<\/code><\/pre>\n<p>Do you expect a ORA-00942: table or view does not exist?<\/p>\n<pre><code>\nSQL&gt; select * from BONUS;\nselect * from BONUS\n              *\nERROR at line 1:\nORA-01775: looping chain of synonyms\n<\/code><\/pre>\n<p>Here is the &#8216;looping chain of synonyms&#8217;. I ask for BONUS. The name resolution first check for an object in my schema, but there are none:<\/p>\n<pre><code>\nSQL&gt; select object_type from user_objects where object_name='BONUS';\nno rows selected\n<\/code><\/pre>\n<p>Then it looks for public synonym and there is one:<\/p>\n<pre><code>\nSQL&gt; select object_type from all_objects where owner='PUBLIC' and object_name='BONUS';\n&nbsp;\nOBJECT_TYPE\n-----------------------\nSYNONYM\n<\/code><\/pre>\n<p>So we check what it is a synonym for:<\/p>\n<pre><code>\nSQL&gt; select table_owner,table_name from all_synonyms where owner='PUBLIC' and synonym_name='BONUS';\n&nbsp;\nTABLE_OWNER  TABLE_NAME\n------------ ------------\nSCOTT        BONUS\n<\/code><\/pre>\n<p>And there it is interesting. Besides the column names that includes &#8216;TABLE&#8217; a synonym can reference any object. So it&#8217;s not just replacing the synonym with &#8216;SCOTT.BONUS&#8217; which would raise an ORA-00942. It is doing name resolution of BONUS in the context of the user SCOTT. Something similar to:<\/p>\n<pre><code>\nSQL&gt; alter session set current_schema=SCOTT;\nSession altered.\nSQL&gt; select * from BONUS;\n<\/code><\/pre>\n<p>And then, what do you expect from that? There is no table named BONUS but there is a public synonym&#8230; and you&#8217;re back to the begining:<\/p>\n<pre><code>\nselect * from BONUS\n              *\nERROR at line 1:\nORA-01775: looping chain of synonyms\n<\/code><\/pre>\n<p>Most of the time, you don&#8217;t have synonyms that reference other synonyms, so you don&#8217;t really have a &#8216;chain&#8217; of synonyms. Except when there is only synonym in the namespace and it&#8217;s a self-reference loop. So if you see ORA-01775, check if the referenced object is not missing.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By Franck Pachot . This error message is misleading. You may encounter it when you expect ORA-00942: table or view does not exist. Let&#8217;s explain<\/p>\n","protected":false},"author":27,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[229],"tags":[96,863],"type_dbi":[],"class_list":["post-8403","post","type-post","status-publish","format-standard","hentry","category-database-administration-monitoring","tag-oracle","tag-synonym"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v27.2 (Yoast SEO v27.2) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>ORA-01775: looping chain of synonyms - dbi Blog<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"ORA-01775: looping chain of synonyms\" \/>\n<meta property=\"og:description\" content=\"By Franck Pachot . This error message is misleading. You may encounter it when you expect ORA-00942: table or view does not exist. Let&#8217;s explain\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/\" \/>\n<meta property=\"og:site_name\" content=\"dbi Blog\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-21T10:13:25+00:00\" \/>\n<meta name=\"author\" content=\"Oracle Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Oracle Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/\"},\"author\":{\"name\":\"Oracle Team\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"headline\":\"ORA-01775: looping chain of synonyms\",\"datePublished\":\"2016-06-21T10:13:25+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/\"},\"wordCount\":371,\"commentCount\":0,\"keywords\":[\"Oracle\",\"synonym\"],\"articleSection\":[\"Database Administration &amp; Monitoring\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/\",\"name\":\"ORA-01775: looping chain of synonyms - dbi Blog\",\"isPartOf\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\"},\"datePublished\":\"2016-06-21T10:13:25+00:00\",\"author\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Accueil\",\"item\":\"https:\/\/www.dbi-services.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"ORA-01775: looping chain of synonyms\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#website\",\"url\":\"https:\/\/www.dbi-services.com\/blog\/\",\"name\":\"dbi Blog\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee\",\"name\":\"Oracle Team\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g\",\"caption\":\"Oracle Team\"},\"url\":\"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"ORA-01775: looping chain of synonyms - dbi Blog","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/","og_locale":"en_US","og_type":"article","og_title":"ORA-01775: looping chain of synonyms","og_description":"By Franck Pachot . This error message is misleading. You may encounter it when you expect ORA-00942: table or view does not exist. Let&#8217;s explain","og_url":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/","og_site_name":"dbi Blog","article_published_time":"2016-06-21T10:13:25+00:00","author":"Oracle Team","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Oracle Team","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/#article","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/"},"author":{"name":"Oracle Team","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"headline":"ORA-01775: looping chain of synonyms","datePublished":"2016-06-21T10:13:25+00:00","mainEntityOfPage":{"@id":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/"},"wordCount":371,"commentCount":0,"keywords":["Oracle","synonym"],"articleSection":["Database Administration &amp; Monitoring"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/","url":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/","name":"ORA-01775: looping chain of synonyms - dbi Blog","isPartOf":{"@id":"https:\/\/www.dbi-services.com\/blog\/#website"},"datePublished":"2016-06-21T10:13:25+00:00","author":{"@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee"},"breadcrumb":{"@id":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.dbi-services.com\/blog\/ora-01775-looping-chain-of-synonyms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Accueil","item":"https:\/\/www.dbi-services.com\/blog\/"},{"@type":"ListItem","position":2,"name":"ORA-01775: looping chain of synonyms"}]},{"@type":"WebSite","@id":"https:\/\/www.dbi-services.com\/blog\/#website","url":"https:\/\/www.dbi-services.com\/blog\/","name":"dbi Blog","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.dbi-services.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.dbi-services.com\/blog\/#\/schema\/person\/66ab87129f2d357f09971bc7936a77ee","name":"Oracle Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f711f7cd2c9b09bf2627133755b569fb5be0694810cfd33033bdd095fedba86d?s=96&d=mm&r=g","caption":"Oracle Team"},"url":"https:\/\/www.dbi-services.com\/blog\/author\/oracle-team\/"}]}},"_links":{"self":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/8403","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/users\/27"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/comments?post=8403"}],"version-history":[{"count":0,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/posts\/8403\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/media?parent=8403"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/categories?post=8403"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/tags?post=8403"},{"taxonomy":"type","embeddable":true,"href":"https:\/\/www.dbi-services.com\/blog\/wp-json\/wp\/v2\/type_dbi?post=8403"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}