Vineet Vineet - 5 months ago 29
SQL Question

What is the difference between single and double quotes in SQL?

What is the difference between single quotes and double quotes in SQL?


Single quotes are used to indicate the beginning and end of a string in SQL. Double quotes generally aren't used in SQL, but that can vary from database to database.

Stick to using single quotes.

That's the primary use anyways. You can use single quotes for a column alias—where you want the column name you reference in your application code to be something other than what the column is actually called in the database. For example: would be more readable as product_id, so you use either of the following:

  • SELECT AS product_id
  • SELECT 'product_id'

Either works in Oracle, SQL Server, MySQL … but I know some have said that the TOAD IDE seems to give some grief when using the single quotes approach.

You do have to use single quotes when the column alias includes a space character, e.g., product id, but it's not recommended practice for a column alias to be more than one word.