question archive How are string literals delimited in SQL?

How are string literals delimited in SQL?

Subject:Computer SciencePrice:2.89 Bought3

How are string literals delimited in SQL?

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE

Answer Preview

A string literal is a series of characters interpreted as one block and is used as one. Literal strings types are used everywhere in SQL. A column of a table with STRING or VARCHAR data type represents string literals when used in the select statement.

Examples of literal strings are the following:
'Hello World’
'+1-3342021407’
'1B, Bakers Street, London, UK’
'Greg House, Dr’


String literals have a defined start and end. We call this property as delimited, and the character that defines where a literal starts and where it ends is called a delimiter. In SQL, the standard delimiter is the single quote character: ‘.

In all the above examples we used a single quote to define the string literal.

SQL also supports the usage of double quote character: ” as a delimiter. The following are also valid examples of string literals.
"Hello World"
"+1-3342021407"
"1B, Bakers Street, London, UK"
"Greg House, Dr"


Point to be remembered:
In some SQL databases, double quotes may not be used as a delimiter. In MySQL, for example, double quotes can be used as a delimiter only if the ANSI_QUOTES option is disabled. Otherwise, only single quotes can be used as a delimiter for strings