I'm using Oracle 10g and I'm having a problem inserting a string with double quotes into a table. This is my statement
INSERT INTO USERS (ID, NAME, USERNAME) VALUES (NULL, "tes", "hello");
The query above fails with the error "Oracle column not allowed here".
If I change double quotes to single quotes, as below the statement is successful.
INSERT INTO USERS (ID, NAME, USERNAME) VALUES (NULL, 'tes', 'hello');
But, I want to insert the double quotes into the table.
Is it possible to have double quote in strings in an insert statement? I don't want to use REPLACE() because my query is automatically generated from an array.
The basic double-quoted string is a series of characters surrounded by double quotes. If you need to use the double quote inside the string, you can use the backslash character.
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.
To specify nested quotation marks within an SQL statement in programs, use the C escape character for every double quotation mark inside a string that is delimited by single quotation marks.
To include a double quote character in a string, type it twice ("") inside the larger string. Thus "Hello" is a string, as is "She said, ""How are you? """.
It is possible. In Oracle, you quote string literals using single quotes.
If you want to insert test
into the database then you must quote that as 'test'
.
INSERT INTO USERS (NAME) VALUES ('test');
If you want to insert "test"
into the database then you must quote that as '"test"'
.
INSERT INTO USERS (NAME) VALUES ('"test"');
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