SQL standard supports single-quoted strings '..' with repeated quote '' used for escaping.
The real world implementations have lots of variation:
- BigQuery:
"..",'..',"""...""",'''..'''(backslash\used for escaping)R"..",r'''..'''the same as above, but withrorRprefix (backlashes not used for escaping)B"..",b'''..'''the same as above, but withborBprefix (backlashes not used for escaping)RB"..",br'''..'''the same as above, but with additionalrorRprefix (backlashes not used for escaping)
- DB2:
'..'(two single quotes''are used for escaping)X'..'a hex string (no escaping)U&'..'an unicode string (two single quotes''are used for escaping)G'..',N'..'a graphic stringGX'..'a graphic hex string (no escaping)UX'..'an UCS-2 graphic string (no escaping)
- Hive:
'..',".."(backslash\used for escaping) - MariaDB:
'..'(backslash\1 or repeated single-quote''used for escaping)x'..',X'..'hex string
- MySQL:
'..',".."2 (backslash\1 or repeated quote (''or"") used for escaping)x'..',X'..'hex string
- N1QL:
".."(backslash\used for escaping) - PL/SQL:
'..'(two single quotes''are used for escaping)N'..',n'..'a string using a natural character setQ'x..x',q'x..x'wherexis a custom delimiter characterq'{..}',q'[..]',q'<..>',q'(..)'special handling for certain delimiters in above syntax
- PostgreSQL:
'..'(two single quotes''are used for escaping)E'..',e'..'string with C-style escapes (backslash\or repeated single-quote''used for escaping)U&'..',u&'..'string with unicode escapes$$..$$,$delim$..$delim$dollar-quoted string with optional custom delimitersB'..',b'..'bit stringX'..',x'..'hex string
- Redshift:
'..' - Spark:
'..'(backslash\used for escaping)X'..'hex string
- SQLite:
'..'(two single quotes''are used for escaping)X'..',x'..'hex string
- Transact-SQL:
'..'(two single quotes''are used for escaping)- (
".."3) N'..'(N".."3) unicode strings
- unless the SQL_MODE has been set to NO_BACKSLASH_ESCAPES.
- unless ANSI_QUOTES mode is enabled.
- if the QUOTED_IDENTIFIER option has been set OFF.