Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p><code>SIZE</code> is a reserved keyword. That means we cannot use it as an identifier (unless we put it in double quotes, but <a href="https://stackoverflow.com/a/6030439/146325">double-quoted identifiers are Teh Suck!</a> so don't do that). Change the column name to <code>ROOMSIZE</code> and <a href="http://www.sqlfiddle.com/#!4/616b3" rel="nofollow noreferrer">your statement will run</a>.</p> <p>Note that <code>TYPE</code> is also a keyword but not reserved. So we are allowed to use it as a column identifier. Types weren't introduced until 8; making <code>TYPE</code> a reserved keyword would have broken code in Oracle applications all over the world, not least in its own data dictionary.</p> <p>The documentation has a complete list of the reserved words. <a href="http://docs.oracle.com/cd/E11882_01/server.112/e41084/ap_keywd001.htm#BABCJAEB" rel="nofollow noreferrer">Find it here</a>.</p> <hr> <p>Why would using <code>"SIZE"</code> be such a bad idea? After all, as @JavaBeginner says, the SQL standard does permit it.</p> <p>Once we choose to use double-quotes to get around Oracle's naming rules we are condemned to use them <em>whenever</em> we reference the column. Hence this would not be a valid query:</p> <pre><code> select no_room, size from room where size &gt; 10 </code></pre> <p>We would have to write instead:</p> <pre><code> select no_room, "SIZE" from room where "SIZE" &gt; 10 </code></pre> <p>And it always have to be <code>"SIZE"</code>: <code>"size"</code> is a different identifier. so is <code>"Size"</code>.</p> <p>Best practice is the informed interpretation of what the standards permit. SQL allows us to do things which we shouldn't do if we want to build a robust and maintainable database. Not using double-quoted identifiers falls into that category. </p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload