How to enter a single quotation mark in Oracle?
来源:互联网 发布:淘宝销售教程 编辑:程序博客网 时间:2024/06/06 09:22
Answer: Although this may be a undervalued question, I got many a search for my blog with this question. This is where I wanted to address this question elaborately or rather in multiple ways.
Method 1
The most simple and most used way is to use a single quotation mark with two single quotation marks in both sides.
SELECT 'test single quote''' from dual;
The output of the above statement would be:
test single quote'
Simply stating you require an additional single quote character to print a single quote character. That is if you put two single quote characters Oracle will print one. The first one acts like an escape character.
This is the simplest way to print single quotation marks in Oracle. But it will get complex when you have to print a set of quotation marks instead of just one. In this situation the following method works fine. But it requires some more typing labour.
Method 2
I like this method personally because it is easy to read and less complex to understand. I append a single quote character either from a variable or use the CHR() function to insert the single quote character.
The same example inside PL/SQL I will use like following:
DECLARE l_single_quote CHAR(1) := ''''; l_output VARCHAR2(20);BEGIN SELECT 'test single quote'||l_single_quote INTO l_output FROM dual; DBMS_OUTPUT.PUT_LINE(l_single_quote);END;
The output above is same as the Method 1.
Now my favourite while in SQL is CHR(39) function. This is what I would have used personally:
SELECT 'test single quote'||CHR(39) FROM dual;
The output is same in all the cases.
Now don't ask me any other methods, when I come to know of any other methods I will share here.
Regards,
Anantha
- How to enter a single quotation mark in Oracle?
- How to display column values in a single cell in Web Intelligence using Oracle database ?
- How to enter text into a textfield in a web view using UIAutomation
- Magento: How to list all the products in a single category in a sidebar block
- How To Add Bookmark (mark) In Pycharm
- How To Add Bookmark (mark) In Pycharm
- how to compile a single kerel module to ko in android
- How to Make a Single Page Website
- OGG How to Resync Tables / Schemas on Different SCN s in a Single Replicat
- How to Submit a Form with Control + Enter
- PowerShell - How to enter a multi-line command
- CC150 3.1 Three in one: describe how you could use a single array to implement 3 stacks.
- How to Increase CSS Misscount in single instance ASM installations
- How to build multiple targets from a single Xcode Project
- How To Open Number Of Sites With A Single Click ?
- How to Succeed in A Professional Career
- How To: Implement A Server Plug-in
- How to create a user in PostgreSQL
- C语言内存分配
- 陈式太极内功修练
- 成年人必看的六个故事,希望有所启发[转]
- 美国机构评出IT行业十大圣地 中关村名列第六
- 怎样使超链接呈块状显示?
- How to enter a single quotation mark in Oracle?
- IT历史上三次10亿刀的收购
- 博客搬家到http://hi.baidu.com/calfpc
- 陈氏太极拳的刚与柔
- 安装jseclipse到myeclipse6.5中
- 陈氏太极拳的刚与柔
- 贴近需求—2009首届Zoomla!逐浪软件应用体验与开发交流会侧记
- 陈氏太极拳技击法
- lose weight...