Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Interested in getting your voice heard by members of the Developer Marketing team at Oracle? Check out this post for AppDev or this post for AI focus group information.

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

536364Oct 23 2009 — edited Oct 23 2009
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.
This post has been answered by Hoek on Oct 23 2009
Jump to Answer

Comments

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).
Hoek
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
Marked as Answer by 536364 · Sep 27 2020
1 - 2
Locked Post
New comments cannot be posted to this locked post.

Post Details

Locked on Nov 20 2009
Added on Oct 23 2009
2 comments
36,874 views