{"Entry":{"collection":"func","key":"quote-literal","name":"quote_literal","aliases":[],"metadata":{"changed_in":["8.2","8.3"],"changes":[{"descriptions_changed":false,"doc_overhaul":false,"from":"7.2","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"added","to":"7.3"},{"descriptions_changed":true,"doc_overhaul":false,"from":"7.3","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"7.4"},{"descriptions_changed":true,"doc_overhaul":false,"from":"8.1","group_changed":null,"signatures":{"added":["quote_literal ( string ) → text"],"removed":["quote_literal ( string text ) → text"]},"status":"changed","to":"8.2"},{"descriptions_changed":false,"doc_overhaul":false,"from":"8.2","group_changed":null,"signatures":{"added":["quote_literal ( string text ) → text","quote_literal ( value anyelement ) → text"],"removed":["quote_literal ( string ) → text"]},"status":"changed","to":"8.3"},{"descriptions_changed":true,"doc_overhaul":false,"from":"8.3","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"8.4"},{"descriptions_changed":true,"doc_overhaul":false,"from":"8.4","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"9.0"},{"descriptions_changed":true,"doc_overhaul":false,"from":"9.2","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"9.3"},{"descriptions_changed":true,"doc_overhaul":false,"from":"9.5","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"9.6"},{"descriptions_changed":true,"doc_overhaul":false,"from":"9.6","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"10"},{"descriptions_changed":true,"doc_overhaul":false,"from":"10","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"11"},{"descriptions_changed":true,"doc_overhaul":false,"from":"11","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"12"},{"descriptions_changed":false,"doc_overhaul":true,"from":"12","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"13"},{"descriptions_changed":true,"doc_overhaul":false,"from":"13","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"14"},{"descriptions_changed":true,"doc_overhaul":false,"from":"16","group_changed":null,"signatures":{"added":[],"removed":[]},"status":"changed","to":"17"}],"content_hash":"56dc29a54c4d906a42792e1de077ecd67b5e8c8bd966b51a8090b2adf7bf22c8","derived_content_hash":"9de3cb1a20204cd3a8ae68f4bee65c13fce079d8305d0b4f0d00bc416cb02dda","documentation_refresh":{"batch":"20261113","original_source_rev":"wiki-repair-20261023:fe9183fc044e66fc29715b4bc44ac4099b6c2411bd0261832e29ecfc9dad4b64","versions":{"14":"14.25","15":"15.20","16":"16.16","17":"17.12","18":"18.7","19":"19rc2"}},"first_version":"7.3","group":"string","group_label":"String Functions And Operators","groups":["string"],"imported_at":"2026-09-27T17:57:28.382982+08:00","last_version":"20","name":"quote_literal","name_key":"quote_literal","position":3025,"present_in":["7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6","10","11","12","13","14","15","16","17","18","19","20"],"repair_provenance":{"original_source_revision":"wiki-repair-20261023:400866da82cf5293cea00dd7aa66f55bcd2dc90770811cd455ecbf69c0c1e464","receipt_sha256":"e0ac951acec46caf5e38f4eba68f8eba592a4490cf790d2653b3e46fded8fd33","repair":"wiki-repair-20261023"},"signature":"quote_literal ( text ) → text","signature_count":2,"slug":"quote-literal","source_rev":"wiki-repair-20261023:fe9183fc044e66fc29715b4bc44ac4099b6c2411bd0261832e29ecfc9dad4b64","summary":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string.","summary_zh":""}},"Definition":{"Collection":"func","Key":"quote-literal","SourceDatabase":"center","Version":"18","SourceTable":"func","SourceKey":"quote-literal","SourceRevision":"wiki-repair-20261023:fe9183fc044e66fc29715b4bc44ac4099b6c2411bd0261832e29ecfc9dad4b64","Facts":{"description":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also Example 41.1.","description_html":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that \u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e returns null on null input; if the argument might be null, \u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e is often more suitable. See also \u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"Example 41.1. Quoting Values in Dynamic Queries\"\u003eExample 41.1\u003c/a\u003e.","description_zh":"为给定字符串添加适当的引号并返回，使其可用作 SQL 语句字符串中的字符串字面量。内嵌的单引号和反斜杠会被适当地双写。注意，quote_literal 在输入为 null 时返回 null；如果参数可能为 null，quote_nullable 通常更合适。另见例 41.1。","description_zh_html":"为给定字符串添加适当的引号并返回，使其可用作 SQL 语句字符串中的字符串字面量。内嵌的单引号和反斜杠会被适当地双写。注意，\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e 在输入为 null 时返回 null；如果参数可能为 null，\u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e 通常更合适。另见\u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"例 41.1. 在动态查询中为值加引号\"\u003e例 41.1\u003c/a\u003e。","doc":{"anchor":"FUNCTIONS-STRING-OTHER","file":"functions-string.html","sha256":"dbe9f91e55c35969d99a8d2697b6f7bd5388a24ccc2b89706a666f176025f1e2","slug":"18"},"documentation_revision":{"inputs":[{"file":"functions-string.html","kind":"same-version-reviewed-manual","locale":"en","sha256":"dbe9f91e55c35969d99a8d2697b6f7bd5388a24ccc2b89706a666f176025f1e2","version":"18.7"},{"file":"functions-string.html","kind":"same-version-reviewed-manual","locale":"zh-Hans","sha256":"7eecd3bb343149124be0476a539f3c682476eab2a15489a0e0ad06fbb769ea9e","version":"18.7"}],"release":"18.7","runtime_remeasured":false,"source_revision":"pgdoc:b9f0e7232f60f380d642ac9b99226606c254b552"},"group":"string","group_label":"字符串函数和操作符","lang":"en","layout":"table-new","pages":["functions-string.html"],"prose_only":false,"signatures":[{"description":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also Example 41.1.","description_html":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that \u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e returns null on null input; if the argument might be null, \u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e is often more suitable. See also \u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"Example 41.1. Quoting Values in Dynamic Queries\"\u003eExample 41.1\u003c/a\u003e.","description_zh":"为给定字符串添加适当的引号并返回，使其可用作 SQL 语句字符串中的字符串字面量。内嵌的单引号和反斜杠会被适当地双写。注意，quote_literal 在输入为 null 时返回 null；如果参数可能为 null，quote_nullable 通常更合适。另见例 41.1。","description_zh_html":"为给定字符串添加适当的引号并返回，使其可用作 SQL 语句字符串中的字符串字面量。内嵌的单引号和反斜杠会被适当地双写。注意，\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e 在输入为 null 时返回 null；如果参数可能为 null，\u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e 通常更合适。另见\u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"例 41.1. 在动态查询中为值加引号\"\u003e例 41.1\u003c/a\u003e。","examples":[{"expr":"quote_literal(E'O\\'Reilly')","result":"'O''Reilly'"}],"html":"\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"quote_literal ( text ) → text","zh_from":"same-version-manual"},{"description":"Converts the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled.","description_html":"Converts the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled.","description_zh":"将给定值转换为文本，然后作为字面量加引号。内嵌的单引号和反斜杠会被适当地双写。","description_zh_html":"将给定值转换为文本，然后作为字面量加引号。内嵌的单引号和反斜杠会被适当地双写。","examples":[{"expr":"quote_literal(42.5)","result":"'42.5'"}],"html":"\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e ( \u003ccode class=\"type\"\u003eanyelement\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"quote_literal ( anyelement ) → text","zh_from":"same-version-manual"}],"translation_provenance":{"inputs":[{"kind":"current-pgdoc-translation","path":"/Users/vonng/pgsty/pgdoc/zh/18/html/functions-string.html","sha256":"0446377e0eccc9299099dc4b4b293204c337e3abefcdc396e9698bc54dd1080b"}],"kind":"same-version-pgdoc","locale":"zh-Hans","source_revision":"b1b500221dbe5437cfca004d6b04d3f6e422765d","version":"18"},"zh_from":"same-version-manual"},"ManualEvidence":{"doc":{"anchor":"FUNCTIONS-STRING-OTHER","file":"functions-string.html","sha256":"dbe9f91e55c35969d99a8d2697b6f7bd5388a24ccc2b89706a666f176025f1e2","slug":"18"}},"MeasuredEvidence":{}},"Text":{"Collection":"func","Key":"quote-literal","SourceDatabase":"center","Version":"18","Locale":"en","Title":"quote_literal","Summary":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also Example 41.1.","BodyHTML":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that \u003ccode\u003equote_literal\u003c/code\u003e returns null on null input; if the argument might be null, \u003ccode\u003equote_nullable\u003c/code\u003e is often more suitable. See also \u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" rel=\"nofollow\"\u003eExample 41.1\u003c/a\u003e.","SourceRevision":"wiki-repair-20261023:fe9183fc044e66fc29715b4bc44ac4099b6c2411bd0261832e29ecfc9dad4b64","ContentHash":"7f41e0506fedf2c42da68c619bf4c3d3b465884c0e69c65c4ffc4df808357c3e","Payload":{"description":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also Example 41.1.","description_html":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that \u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e returns null on null input; if the argument might be null, \u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e is often more suitable. See also \u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"Example 41.1. Quoting Values in Dynamic Queries\"\u003eExample 41.1\u003c/a\u003e.","signatures":[{"description":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also Example 41.1.","description_html":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that \u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e returns null on null input; if the argument might be null, \u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e is often more suitable. See also \u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"Example 41.1. Quoting Values in Dynamic Queries\"\u003eExample 41.1\u003c/a\u003e.","description_zh":"为给定字符串添加适当的引号并返回，使其可用作 SQL 语句字符串中的字符串字面量。内嵌的单引号和反斜杠会被适当地双写。注意，quote_literal 在输入为 null 时返回 null；如果参数可能为 null，quote_nullable 通常更合适。另见例 41.1。","description_zh_html":"为给定字符串添加适当的引号并返回，使其可用作 SQL 语句字符串中的字符串字面量。内嵌的单引号和反斜杠会被适当地双写。注意，\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e 在输入为 null 时返回 null；如果参数可能为 null，\u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e 通常更合适。另见\u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"例 41.1. 在动态查询中为值加引号\"\u003e例 41.1\u003c/a\u003e。","examples":[{"expr":"quote_literal(E'O\\'Reilly')","result":"'O''Reilly'"}],"html":"\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"quote_literal ( text ) → text","zh_from":"same-version-manual"},{"description":"Converts the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled.","description_html":"Converts the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled.","description_zh":"将给定值转换为文本，然后作为字面量加引号。内嵌的单引号和反斜杠会被适当地双写。","description_zh_html":"将给定值转换为文本，然后作为字面量加引号。内嵌的单引号和反斜杠会被适当地双写。","examples":[{"expr":"quote_literal(42.5)","result":"'42.5'"}],"html":"\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e ( \u003ccode class=\"type\"\u003eanyelement\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"quote_literal ( anyelement ) → text","zh_from":"same-version-manual"}]}},"RequestedLocale":"en","Fallback":false,"Versions":["10","11","12","13","14","15","16","17","18","19","20","7.3","7.4","8.0","8.1","8.2","8.3","8.4","9.0","9.1","9.2","9.3","9.4","9.5","9.6"],"Locales":["en","zh-Hans"],"Signatures":[{"Version":"18","Ordinal":0,"Hash":"95cab551fadada04e85fdf71c6ae8ce165e97ea873cc0e6de35a99116be9ad39","Text":"quote_literal ( text ) → text","Returns":"text","Payload":{"description":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that quote_literal returns null on null input; if the argument might be null, quote_nullable is often more suitable. See also Example 41.1.","description_html":"Returns the given string suitably quoted to be used as a string literal in an SQL statement string. Embedded single-quotes and backslashes are properly doubled. Note that \u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e returns null on null input; if the argument might be null, \u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e is often more suitable. See also \u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"Example 41.1. Quoting Values in Dynamic Queries\"\u003eExample 41.1\u003c/a\u003e.","description_zh":"为给定字符串添加适当的引号并返回，使其可用作 SQL 语句字符串中的字符串字面量。内嵌的单引号和反斜杠会被适当地双写。注意，quote_literal 在输入为 null 时返回 null；如果参数可能为 null，quote_nullable 通常更合适。另见例 41.1。","description_zh_html":"为给定字符串添加适当的引号并返回，使其可用作 SQL 语句字符串中的字符串字面量。内嵌的单引号和反斜杠会被适当地双写。注意，\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e 在输入为 null 时返回 null；如果参数可能为 null，\u003ccode class=\"function\"\u003equote_nullable\u003c/code\u003e 通常更合适。另见\u003ca href=\"/docs/18/plpgsql-statements.html#PLPGSQL-QUOTE-LITERAL-EXAMPLE\" title=\"例 41.1. 在动态查询中为值加引号\"\u003e例 41.1\u003c/a\u003e。","examples":[{"expr":"quote_literal(E'O\\'Reilly')","result":"'O''Reilly'"}],"html":"\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e ( \u003ccode class=\"type\"\u003etext\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"quote_literal ( text ) → text","zh_from":"same-version-manual"}},{"Version":"18","Ordinal":1,"Hash":"8b7ab2afbf1c41a8a735439e1c5936d3e670281b919eb0bf23cce6abbc5c98c3","Text":"quote_literal ( anyelement ) → text","Returns":"text","Payload":{"description":"Converts the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled.","description_html":"Converts the given value to text and then quotes it as a literal. Embedded single-quotes and backslashes are properly doubled.","description_zh":"将给定值转换为文本，然后作为字面量加引号。内嵌的单引号和反斜杠会被适当地双写。","description_zh_html":"将给定值转换为文本，然后作为字面量加引号。内嵌的单引号和反斜杠会被适当地双写。","examples":[{"expr":"quote_literal(42.5)","result":"'42.5'"}],"html":"\u003ccode class=\"function\"\u003equote_literal\u003c/code\u003e ( \u003ccode class=\"type\"\u003eanyelement\u003c/code\u003e ) → \u003ccode class=\"returnvalue\"\u003etext\u003c/code\u003e","returns":"text","text":"quote_literal ( anyelement ) → text","zh_from":"same-version-manual"}}],"Spellings":null,"SQLState":null,"Evidence":null}
