Difference between single and double quotes in SQL

0 votes
Hi!!

Can someone tell me what is the difference between single and doubt quotes in SQL?
Sep 11, 2018 in Database by darklord
• 6,170 points
97 views

1 answer to this question.

0 votes

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 anyway. 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: PRODUCT.id would be more readable as product_id, so you use either of the following:

  • SELECT PRODUCT.id AS product_id
  • SELECT PRODUCT.id '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.

answered Sep 11, 2018 by CodingByHeart77
• 3,690 points

Related Questions In Database

0 votes
1 answer

Difference between clustered and non clustered index in SQL

The differences between the clustered and non ...READ MORE

answered Sep 28, 2018 in Database by darklord
• 6,170 points
109 views
+1 vote
2 answers

Difference between SQL and PL/SQL

In Oracle database administration, there are two ...READ MORE

answered Sep 25 in Database by gautham
207 views
0 votes
1 answer

Can you please explain the difference between inner join and outer join in database?

Hi Suraj, You have a doubt regarding inner join ...READ MORE

answered May 28 in Database by sampriti
• 1,100 points
96 views
0 votes
1 answer

STUFF and REPLACE function in SQL

STUFF Function: This function is used to ...READ MORE

answered Sep 27, 2018 in Database by DataKing99
• 8,130 points
95 views
0 votes
1 answer

How to connect Java program to the MySQL database?

You can connect your Java code with ...READ MORE

answered May 11, 2018 in Java by parth295
• 4,640 points
212 views
0 votes
1 answer

Is SELECT * harmful in Database?

There are really three major reasons: Inefficiency in ...READ MORE

answered Sep 7, 2018 in Database by DataKing99
• 8,130 points
52 views
0 votes
1 answer

Can different databases use different name quotes?

This use of quotes is called delimited ...READ MORE

answered Sep 11, 2018 in Database by CodingByHeart77
• 3,690 points
37 views
0 votes
1 answer

Write a SQL query to find the names of employees that begin with ‘S’

To display the name of the employees ...READ MORE

answered Sep 26, 2018 in Database by darklord
• 6,170 points
55 views
0 votes
1 answer

Difference between primary key a composite key

Primary key is that column of the table ...READ MORE

answered Sep 5, 2018 in Database by CodingByHeart77
• 3,690 points
1,795 views
0 votes
1 answer

Difference between STUFF & REPLACE function

STUFF Function: This function is used to ...READ MORE

answered Oct 10, 2018 in Database by CodingByHeart77
• 3,690 points
736 views