2 Replies Latest reply on Oct 23, 2009 7:23 PM by Hoek

    What is the difference between single quote (') and double quote(")  ?

    536364
      What is the difference between single quote (') and double quote(") in relates to using in SQL. When do you use 'xxx' and "xxx"? what is the difference both of them?

      Thanks.
        • 1. Re: What is the difference between single quote (') and double quote(")  ?
          Frank Kulash
          Hi,

          Single-quotes are used to enclose string literals (and, in recent versions, DATE literals).

          Double-quotes are used to enclose identifiers (like table and column names) . They are optional (and therefore almost never used) when the name conforms to certain rules for names (starts with a letter, no spaces or special symbols, no lower-case letters, ...).

          For example
          SELECT  'Hello, world!'    AS "My Greeting"
          FROM    dual;
          Output:
          My Greeting
          -------------
          Hello, world!
          'Hello, world!' is a string literal, so it is enclosed in single-quotes.
          The column alias "My Greeting" is not a normal identifier name: it contans lower-case letters and a space, so it must be enclosed in double-quotes.
          The table name DUAL is a normal identifer: it is all capital letters, no spaces. I have the choice of referring to it as "DUAL" (all capital letters, inside double-quotes) or as DUAL, dual, Dual, dUAL, dUaL, ... (without quotes).
          • 2. Re: What is the difference between single quote (') and double quote(")  ?
            Hoek
            http://download.oracle.com/docs/cd/E11882_01/server.112/e10592/sql_elements008.htm#SQLRF51129
            http://download.oracle.com/docs/cd/E11882_01/appdev.112/e10472/fundamentals.htm#LNPLS199

            edit
            what is the difference both of them?
            Actually: it's best to just forget about the double quotes ;)

            Edited by: hoek on Oct 23, 2009 9:22 PM