I’m programmatically transferring data between a DB2 server and an Apache Derby (JavaDB) server.
The DB2 server has a number of tables with column names that include the pound sign (#) character. However, when trying to create tables in Derby:
CREATE TABLE LIBNAME.TABNAME
(COL# decimal(3,0),
REC# decimal(5,0),
DESC char(30,0),
SDSC char(10,0));
I get the following error:
ERROR 42X02: Lexical error at line 1, column 38. Encountered: “#” (35), after : “”
The Derby Reference Manual is no help; the given explanation for error code 42X02 is simply <value>
It’s a simple task to remove the pound sign from the column names for Derby and then add it back for DB2, but I’d like to avoid it if I can.
Does anyone happen to know if Derby simply doesn’t allow the # character (and why?) or if I’m doing something wrong…
According to the Derby reference manual (Rules for SQL92 Identifiers):
So,
COL#appears to be invalid as an ordinary identifier because of the#."COL#"would probably be valid as a delimited identifier, but I haven’t tested this.