Site icon NgDeveloper

How to Insert Single and Double Quotes in Oracle?

How to Insert Single and Double Quotes in Oracle?

Inserting Single quote in oracle:

If your query is like this,

insert into emp (id,name,salary) values (10,’Naveen’s’,10000); // error

then you will get the error for the single quote in the name.

We have to escape it to insert in oracle using one more single quote like this,

insert into emp (id,name,salary) values (10,’Naveen”s’,10000);

 

// it’s fine because we escaped single quote with one more single quote

This will insert as,

10 | Naveen’s | 10000

Inserting Double quote in oracle:
Double quote can be inserted without escaping it in oracle.

Sample query with double quote:

insert into emp (id,name,salary) values (5,’Naveen kumar “Gunasekaran”‘,50000);

This will insert as,

5 | Naveen kumar “Gunasekaran” | 50000

here we did not escape double quote in the oracle insert query.

 

Just Remember:

1. Single quote should be escaped with one more single quote.

2. Double quote can be inserted directly without escaping it.

 

Exit mobile version