A colleague of mine has created an export with INSERT INTO
queries using Oracle SQL Developer. This export has put single quotes around every value, not just VARCHARs.
So let's say we have a simple table containing these columns (among others):
SOME_TEXT VARCHAR2(256 BYTE)
SOME_NUMBER NUMBER(15,2)
The export has an INSERT INTO
like this:
Insert into MY_TABLE (SOME_TEXT,SOME_NUMBER) values ('test text','123,45');
You may note two things about the decimal value ('123,45'
):
- It has single quotes around it
- It has a comma instead of a dot (the database of my colleague is Dutch, and mine is English)
The second is easy to fix, I can insert it in Oracle SQL Developer like this:
-- dot as thousand separator, comma as decimal point
alter SESSION set NLS_NUMERIC_CHARACTERS = '.,';
Insert into MY_TABLE (SOME_TEXT,SOME_NUMBER) values ('test text','123,45');
-- All other insert queries
alter SESSION set NLS_NUMERIC_CHARACTERS = ',.';
Which works fine.
However, some of the .sql
files are very big, and can't be opened in SQL Developer. So instead I want to use SQL Plus to execute the .sql
files containing the insert-statements.
However, even when NLS_NUMERIC_CHARACTERS
is changed, I'm currently getting the following error in SQL Plus due to the single quotes around the numeric value:
SQL> @"C:\my\path\test_insert_statement.sql"
values ('test text','123,45')
*
ERROR at line 2:
ORA-01722: invalid number
I see two possible solutions, but I don't know if either is possible:
- Is there a way to allow single quotes around numeric values in SQL Plus for Oracle databases?
- Or is there a way to export a database without single quotes for numeric values in Oracle SQL Developer (then I can let my colleague generate another
.sql
file)?