我需要从H2控制台插入这个字符串,并使用两层深嵌套引号。由于H2 DB使用单引号,我不能使用双引号。我看到这个SO修复了一个嵌套引号的字符串。
我尝试插入,但是得到这个错误
INSERT INTO Encouragement VALUES(31,'WhoIAmInChrist','NoAnxietyInChrist','Uplifting','God is bigger than our fearful hearts: Isaiah 35:4 '''Say to those with fearful hearts, '''Be strong, do not fear; your God will come, he will come with vengeance; with divine retribution he will come to save you''' ''' (NIV).'
)
INSERT INTO Encouragement VALUES(31,'WhoIAmInChrist','NoAnxietyInChrist','Uplifting','God is bigger than our fearful hearts: Isaiah 35:4 "Say to those with fearful hearts, "Be strong, do not fear; your God will come, he will come with vengeance; with divine retribution he will come to save you'" '" (NIV).');
Syntax error in SQL statement "INSERT INTO Encouragement VALUES(31,'WhoIAmInChrist','NoAnxietyInChrist','Uplifting','God is bigger than our fearful hearts: Isaiah 35:4 \""Say to those with fearful hearts, \""Be strong, do not fear; your God will come, he will come with vengeance; with divine retribution he will come to save you'[*]\"" '\"" (NIV).')"; SQL statement:
INSERT INTO Encouragement VALUES(31,'WhoIAmInChrist','NoAnxietyInChrist','Uplifting','God is bigger than our fearful hearts: Isaiah 35:4 "Say to those with fearful hearts, "Be strong, do not fear; your God will come, he will come with vengeance; with divine retribution he will come to save you'" '" (NIV).') [42000-214] 42000/42000 (Help)
模式如下:
CREATE TYPE Category AS ENUM('WhoIAmInChrist','Default')
CREATE TYPE Tone AS ENUM('Default', 'Uplifting', 'Urging', 'Warning', 'Soothing', 'Comforting', 'Inspiring', 'Centering', 'Balanced')
CREATE TYPE Topic AS ENUM('Default', 'AcceptedInChrist', 'SignificantInChrist', 'SecureInChrist', 'NoAnxietyInChrist');
CREATE TABLE Encouragement(ID INT PRIMARY KEY, CATEGORY Category, TOPIC Topic, TONE Tone, MESSAGE VARCHAR(255))
可以通过重复单引号来转义。例如:
INSERT INTO enc VALUES(31,'God is 35:4 ''Say'' Be strong.');
将插入值God is 35:4 'Say' Be strong.
。