Oracle 10g - Escape quote in insert statement

拈花ヽ惹草 提交于 2019-12-20 02:56:10

问题


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

How do I properly escape the quote 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


回答1:


Oracle uses standard SQL:

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

(Yes there are two single quotes)




回答2:


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




回答3:


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#');


来源:https://stackoverflow.com/questions/5326085/oracle-10g-escape-quote-in-insert-statement

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!