相关疑难解决方法(0)

在PostgreSQL中插入带单引号的文本

我有一张桌子test(id,name).

我需要插入样值: user's log,'my user',customer's.

 insert into test values (1,'user's log');
 insert into test values (2,''my users'');
 insert into test values (3,'customer's');
Run Code Online (Sandbox Code Playgroud)

如果我运行上述任何语句,我会收到错误.

如果有任何方法可以正确地做到这一点请分享.我不想要任何准备好的陈述.

是否可以使用sql转义机制?

postgresql quotes insert special-characters

377
推荐指数
5
解决办法
32万
查看次数

postgresql中的字符串文字和转义字符

尝试将转义字符插入表中会导致警告.

例如:

create table EscapeTest (text varchar(50));

insert into EscapeTest (text) values ('This is the first part \n And this is the second');
Run Code Online (Sandbox Code Playgroud)

产生警告:

WARNING:  nonstandard use of escape in a string literal
Run Code Online (Sandbox Code Playgroud)

(使用PSQL 8.2)

有谁知道怎么解决这个问题?

string postgresql escaping

104
推荐指数
3
解决办法
24万
查看次数