<p>If you've used Oracle, you've probably gotten the helpful message "ORA-00942: Table or view does not exist". Is there a legitimate technical reason the message doesn't include the name of the missing object? </p>

<p>Arguments about this being due to security sound like they were crafted by the TSA. If I'm an attacker, I'd know what table I just attempted to exploit, and be able to interpret this unhelpful message easily. If I'm a developer working with a complex join through several layers of application code, it's often very difficult to tell.</p>

<p>My guess is that when this error was originally implemented, someone neglected to add the object name, and now, people are afraid it will break compatibility to fix it. (Code doing silly things like parsing the error message will be confused if it changes.)</p>

<p>Is there a developer-friendly (as opposed to recruiting your DBA) way to determine the name of the missing table?</p>

<hr>

<p>Although I've accepted an answer which is relevant to the topic, it doesn't really answer my question: <em>Why isn't the name part of the error message?</em> If anyone can come up with the real answer, I'll be happy to change my vote.</p>

[{'answer_id': 46400, 'author': 'Ethan Post', 'author_id': 4527, 'author_profile': 'https://Stackoverflow.com/users/4527', 'pm_score': 5, 'selected': True, 'text': '<p>You can set an EVENT in your parameter file (plain text or spfile) to force Oracle to dump a detailed trace file in the user_dump_dest, the object name might be in there, if not the SQL should be.</p>\n\n<p>EVENT="942 trace name errorstack level 12"</p>\n\n<p>If you are using a plain text file you need to keep all your EVENT settings on consecutive lines. Not sure how that applied to spfile.</p>\n'}, {'answer_id': 46413, 'author': 'Mark Nold', 'author_id': 4134, 'author_profile': 'https://Stackoverflow.com/users/4134', 'pm_score': 3, 'selected': False, 'text': '<p>If you are using a SQL browsing tool like TOAD or TORA it will help you with ORA errors by highlightling or pointing moving the cursor to where you made your error.</p>\n\n<p>Copy and paste your SQL in to one of these tools to help. You may also find the analyse info available useful too.</p>\n'}, {'answer_id': 47143, 'author': 'Matthew Watson', 'author_id': 3839, 'author_profile': 'https://Stackoverflow.com/users/3839', 'pm_score': 2, 'selected': False, 'text': "<p>If its not a huge statement, then the easiest way is just to check the data dictionary,</p>\n\n<pre><code>SQL&gt; select * from xx,abc;\nselect * from xx,abc\n                 *\nERROR at line 1:\nORA-00942: table or view does not exist\n\n\nSQL&gt; select owner,table_name from all_tables where table_name in ('XX','ABC');\n\nOWNER                          TABLE_NAME\n------------------------------ ------------------------------\nMWATSON                        XX\n\nSQL&gt; \n</code></pre>\n\n<p>This isn't ideal, but short of going and examining trace files, I'm not sure how else to do it.</p>\n"}, {'answer_id': 48411, 'author': 'Hobo', 'author_id': 1714, 'author_profile': 'https://Stackoverflow.com/users/1714', 'pm_score': 1, 'selected': False, 'text': "<p>@Matthew</p>\n\n<p>Your query's a start, but it might not work when you have multiple schemas.  For example, if I log into our instance as myself, I have read access to all our tables.  But if I don't qualify the table name with the schema I'll get an ORA-00942 for tables without synonyms:</p>\n\n<pre>\nSQL> select * from tools; \nselect * from tools \n              * \nERROR at line 1: \nORA-00942: table or view does not exist \n</pre>\n\n<p>The table still shows up in all_tables though:</p>\n\n<pre>\nSQL> select owner, table_name from all_tables where table_name = 'TOOLS'; \n\nOWNER                          TABLE_NAME \n------------------------------ ------------------------------ \nAPPLICATION                    TOOLS \n</pre>\n\n<p>@erikson\nSorry that doesn't help much.  I'm with Mark - I used TOAD.</p>\n"}, {'answer_id': 52118, 'author': 'Nick Pierpoint', 'author_id': 4003, 'author_profile': 'https://Stackoverflow.com/users/4003', 'pm_score': 4, 'selected': False, 'text': "<p>SQL*Plus does tell you the table that doesn't exist. For example:</p>\n\n<pre><code>SQL&gt; select\n  2     *\n  3  from\n  4     user_tables a,\n  5     non_existent_table b\n  6  where\n  7     a.table_name = b.table_name;\n   non_existent_table b\n   *\nERROR at line 5:\nORA-00942: table or view does not exist\n</code></pre>\n\n<p>Here it shows that the name of the missing table and the line number in the SQL statement where the error occurs.</p>\n\n<p>Similarly, in a one-line SQL statement you can see the asterisk highlighting the name of the unknown table:</p>\n\n<pre><code>SQL&gt; select * from user_tables a, non_existent_table b where a.table_name = b.table_name;\nselect * from user_tables a, non_existent_table b where a.table_name = b.table_name\n                             *\nERROR at line 1:\nORA-00942: table or view does not exist\n</code></pre>\n\n<p>In terms of your question, I guess the reason the error message doesn't include the name of the table is that the error message itself needs to be static text. The line number and location in the line of the error is clearly passed back to SQL*Plus (somehow).</p>\n"}, {'answer_id': 770553, 'author': 'Jon Ericson', 'author_id': 1438, 'author_profile': 'https://Stackoverflow.com/users/1438', 'pm_score': 2, 'selected': False, 'text': '<p>I\'ve never had a problem with interpreting Oracle error messages.  Part of the reason is that every interactive tool I\'ve seen for developing SQL for Oracle helpfully points to the location the query went wrong.  That includes SQL*Plus, as others have noted, and the Perl DBI module:</p>\n\n<pre><code>$ exec_sql.pl \'select * from daul\'\nDBD::Oracle::db prepare failed: ORA-00942: table or view does not exist (DBD ERROR: error possibly near &lt;*&gt; indicator at char 14 in \'select * from &lt;*&gt;daul\') [for Statement "select * from daul"] at exec_sql.pl line 68.\n</code></pre>\n\n<p>Well, that <strong>is</strong> a bit hard to read since it\'s all squished on one line.  But a GUI tool would be able to point to the token where Oracle started having problems with the query.  And given a bit of work on a parser, you could write a tool to pick out the offending table.</p>\n\n<p>To answer the underlying question, Oracle errors don\'t seem to be designed to work the way you expect.  As far as I can tell, none of the the error messages in Oracle support variable text.  Instead, Oracle returns two bits of information: an error number and a location where the error occurs.  If you have proper tools, it\'s pretty easy to diagnose an error with those pieces of data.  It can be argued that Oracle\'s system is nicer to tool creators than one which provides variable amounts of diagnostic data depending on the error.  Imagine having to write a custom parser for all of Oracle\'s error messages (including future errors) to highlight the offending location.</p>\n\n<p>Sometimes including the table name would be misleading.  Just knowing where things went wrong can be a huge help:</p>\n\n<pre><code>SQL&gt; select * from where dummy = \'X\';\nselect * from where dummy = \'X\'\n              *\nERROR at line 1:\nORA-00903: invalid table name\n</code></pre>\n\n<p>As for why Oracle chose to do thing this way, I have some speculations:</p>\n\n<ol>\n<li><p>IBM used this style of error message for System R, which Larry Ellison, Bob Miner and Ed Oates copied to build Oracle V2.  (Backward compatibility.)</p></li>\n<li><p>Error number and location are the smallest possible representation of diagnostic information.  (Parsimony.)</p></li>\n<li><p>As I indicated above, to simplify the creation of tools that connect to Oracle.  (Interoperability.)</p></li>\n</ol>\n\n<p>In any case, I don\'t think you need to be a DBA to figure out which table doesn\'t exist.  You just need to use the proper tools.  (And adjust your expectations, I suppose.)</p>\n'}, {'answer_id': 770979, 'author': 'Mark Harrison', 'author_id': 116, 'author_profile': 'https://Stackoverflow.com/users/116', 'pm_score': 2, 'selected': False, 'text': '<p><strong>Reason 1:  Multi-lingual interface</strong></p>\n\n<p>There is a language-specific message configuration file for your database instance.  Messages are pulled out of there and translated from the pure numeric version to the numeric+text version.</p>\n\n<p>It was probably considered better to have the hardcoded strings, than to run the risk at runtime of having a mysterious failure due to an improperly formatted "%s" string.</p>\n\n<p>(Not that I particularly agree with this POV, btw.)</p>\n\n<p><strong>Reason 2: Security</strong></p>\n\n<p>Right now you don\'t particularly expose the internal workings of your application if you print a PHP, etc, dump of an Oracle error message to the browser.</p>\n\n<p>Applications would be a bit more exposed if more detail were printed by default... For example, if citibank printed a more explanatory message.</p>\n\n<p>(see disclaimer above, I would be happy to get more information in the error as well.)</p>\n'}, {'answer_id': 4850892, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 3, 'selected': False, 'text': "<p>I would disagree with the opinion, that SQL+ lets you understand which table name is unacceptable. True, it helps in direct DML, although parsing it is very hard. But when it comes to dynamic, we get no help:</p>\n\n<pre><code>SQL&gt; begin\n  2  execute immediate 'insert into blabla values(1)';\n  3  end;\n  4  /\nbegin\n*\nERROR at line 1:\nORA-00942: table or view does not exist\nORA-06512: at line 2\n</code></pre>\n"}]
['https://Stackoverflow.com/questions/46380', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/3474/']