From 9d3b486828fb5289001e199d6ec8ae4df2fced81 Mon Sep 17 00:00:00 2001 From: jbranchaud Date: Wed, 27 Jan 2016 17:11:22 -0600 Subject: [PATCH] Add Escaping A Quote In A String as a postgres til --- README.md | 1 + postgres/escaping-a-quote-in-a-string.md | 15 +++++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 postgres/escaping-a-quote-in-a-string.md diff --git a/README.md b/README.md index 627a8a0..3b5f048 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/postgres/escaping-a-quote-in-a-string.md b/postgres/escaping-a-quote-in-a-string.md new file mode 100644 index 0000000..97be966 --- /dev/null +++ b/postgres/escaping-a-quote-in-a-string.md @@ -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)