1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 07:08:01 +00:00

Add Escaping A Quote In A String as a postgres til

This commit is contained in:
jbranchaud
2016-01-27 17:11:22 -06:00
parent cd216e0959
commit 9d3b486828
2 changed files with 16 additions and 0 deletions

View File

@@ -139,6 +139,7 @@ _310 TILs and counting..._
- [Default Schema](postgres/default-schema.md)
- [Defining Arrays](postgres/defining-arrays.md)
- [Edit Existing Functions](postgres/edit-existing-functions.md)
- [Escaping A Quote In A String](postgres/escaping-a-quote-in-a-string.md)
- [Export Query Results To A CSV](postgres/export-query-results-to-a-csv.md)
- [Extracting Nested JSON Data](postgres/extracting-nested-json-data.md)
- [Find The Data Directory](postgres/find-the-data-directory.md)

View File

@@ -0,0 +1,15 @@
# Escaping A Quote In A String
In PostgreSQL, strings (`varchar` and `text`) literals are declared with
single quotes (`'`). That means that any string containing a single quote as
part of the content of the string will need some escaping. The way to escape
a single quote is with another single quote.
```sql
> select 'what''s up!';
?column?
------------
what's up!
```
[source](http://jonathansacramento.com/posts/20160122-improve-postgresql-workflow-vim-dbext.html)