The standard syntax for specifying string literals can be difficult to understand. To allow more readable queries in such situations, YugabyteDB’s YSQL provides dollar quoting.
Dollar quoting is not part of the SQL standard, but it is often a more convenient way to write complicated string literals than the standard-compliant single quote syntax.
Example:
Without a dollar-quoted string:
yugabyte=# SELECT 'You don''t have to use '''' ''every'' time you want to display a '' in a ''Dollar-Quoted'' string literal!' "Confusing Syntax";
Confusing Syntax
----------------------------------------------------------------------------------------------------
You don't have to use '' 'every' time you want to display a ' in a 'Dollar-Quoted' string literal!
(1 row)
Using a dollar-quoted string:
yugabyte=# SELECT $$You don't have to use '' 'every' time you want to display a ' in a 'Dollar-Quoted' string literal!$$ "Not Confusing Syntax";
Not Confusing Syntax
----------------------------------------------------------------------------------------------------
You don't have to use '' 'every' time you want to display a ' in a 'Dollar-Quoted' string literal!
(1 row)