Postgres / Flyway:如何在sql文件中包装长常量字符串?

时间:2018-06-15 00:25:24

标签: postgresql flyway

我想在我的flyway迁移文件中对SQL进行换行,工作版本如下:

comment on table account is
'Multiple users may be associated with the same account (think multiple login methods, like gmail + facebook, etc.) ';

如果我使用IDEA并在字符串中按Enter键,则会生成:

comment on table account is
'Multiple users may be associated with the same account (think multiple' ||
' login methods, like gmail + facebook, etc.) ';

但是,然后运行迁移操作会产生错误PSQLException: ERROR: syntax error at or near "||"

版本:Flyway 4.2,Postgres 10

2 个答案:

答案 0 :(得分:1)

在SQL中跨行分割字符串是完全没问题的(没有任何连接运算符):

comment on table account is
'Multiple users may be associated with the 
same account (think multiple login methods, 
like gmail + facebook, etc.)';

答案 1 :(得分:0)

仅包装源代码的替代答案,而不是字符串的内容:

comment on table account is
'Multiple users may be associated with the same account (think multiple'
' login methods, like gmail + facebook, etc.)';