Home >Database >Mysql Tutorial >How to Properly Handle Single Quotes in Oracle SQL Inserts?

How to Properly Handle Single Quotes in Oracle SQL Inserts?

Barbara Streisand
Barbara StreisandOriginal
2025-01-16 19:06:12539browse

How to Properly Handle Single Quotes in Oracle SQL Inserts?

Handling single quotes in Oracle SQL

When inserting varchar column records containing single quotes, special care must be taken to ensure accuracy.

To insert a single quote into a column, double it. For example, if you want to insert "D'COSTA" as a last name:

<code class="language-sql">SQL> SELECT 'D''COSTA' name FROM DUAL;

NAME
-------
D'COSTA</code>

An alternative is to use the newer (10g) quoting method:

<code class="language-sql">SQL> SELECT q'$D'COSTA$' NAME FROM DUAL;

NAME
-------
D'COSTA</code>

The above is the detailed content of How to Properly Handle Single Quotes in Oracle SQL Inserts?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn