开发者

Oracle 10g - Escape quote in insert statement

I am trying to insert people's height into a database in the form of 5'9

How do I properly escape the quo开发者_StackOverflowte so I can do this. My insert statement looks like this so far.

INSERT INTO height(id, height) 
VALUES(height-seq.nexval, '5\'9');

The backslash does not work obviously and I am pretty new to oracle. Thanks


Oracle uses standard SQL:

INSERT INTO height(id, height) 
VALUES(height-seq.nexval, '5''9');

(Yes there are two single quotes)


if you are doing this from a front end using some programming language, consider using a parametrized query, if you are in psql or some other tool to do this, just use '5''9 ' and it will work fine


I hate double quoting, it's a mess. Luckely these days we have the quote operator:

q'{delimiter}string{delimiter}'

INSERT INTO height(id, height) 
VALUES(height-seq.nexval, q'#5'9#');
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜