如何在PostgreSQL中插入新行 [英] How to insert new line in PostgreSQL
本文介绍了如何在PostgreSQL中插入新行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在PostgreSQL查询中列长度> 100时换行,这是我的代码:
I want to make new line when the column length > 100 in PostgreSQL query, here is my code:
SELECT message, CASE WHEN length(message) > 100
THEN message||'\n' end as res FROM msg.list_trx
推荐答案
您缺少 e
就在换行文字之前(对于像c的特殊字符来说是必需的):
You are missing e
right before new line literal (it is required for c-like special chars):
SELECT message, CASE WHEN length(message) > 100
THEN message||e'\n' end as res FROM msg.list_trx
查看 http://www.postgresql.org/ docs / 9.0 / static / sql-syntax-lexical.html
4.1.2.2。带有C样式转义符的字符串常量
4.1.2.2. String Constants with C-Style Escapes
以获取更多信息。
这篇关于如何在PostgreSQL中插入新行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文