Forum Stats

  • 3,875,518 Users
  • 2,266,939 Discussions
  • 7,912,241 Comments

Discussions

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

536364
536364 Member Posts: 82
edited Oct 23, 2009 3:23PM in SQL & PL/SQL
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.

Best Answer

  • Hoek
    Hoek Member Posts: 16,087 Gold Crown
    edited Oct 23, 2009 3:23PM Answer ✓
    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

Answers

  • Frank Kulash
    Frank Kulash Member, Moderator Posts: 42,783 Red Diamond
    edited Oct 23, 2009 3:09PM
    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).
  • Hoek
    Hoek Member Posts: 16,087 Gold Crown
    edited Oct 23, 2009 3:23PM Answer ✓
    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
This discussion has been closed.