How do I insert a record in a column having varchar data type having single quote in it?
Example: first name is ROBERT
and last name is D'COSTA
Single quotes are used to indicate the beginning and end of a string in SQL. Double quotes generally aren't used in SQL, but that can vary from database to database. Stick to using single quotes. That's the primary use anyway.
The most simple and most used way is to use a single quotation mark with two single quotation marks in both sides. 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.
Answer: Now it is first important to remember that in Oracle, you enclose strings in single quotes. The first quote denotes the beginning of the string and the second quote denotes the termination of the string.
Use two single-quotes
SQL> SELECT 'D''COSTA' name FROM DUAL; NAME ------- D'COSTA
Alternatively, use the new (10g+) quoting method:
SQL> SELECT q'$D'COSTA$' NAME FROM DUAL; NAME ------- D'COSTA
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With