I am programmatically moving data from a DB2 server as well as an Apache Derby (JavaDB) server.

The DB2 server has numerous tables with column names which include the pound sign (#) character. However, when attempting to produce tables in Derby:

CREATE TABLE LIBNAME.TABNAME
(COL# decimal(3,0),
REC# decimal(5,0),
DESC char(30,0),
SDSC char(10,0));

I recieve the next error:

ERROR 42X02: Lexical error at line 1, column 38. Experienced: "#" (35), after : ""

The Derby Reference Manual isn't any assist the given reason behind error code 42X02 is just <value>

It's an easy task to get rid of the pound sign in the column names for Derby after which add it back for DB2, but Let me cure it basically can.

Does anybody occur to determine if Derby simply does not permit the # character (and why?) or maybe I am doing a problem...

Based on the Derby reference manual (Rules for SQL92 Identifiers):

Regular identifiers are identifiers not encircled by double quotes. Delimited identifiers are identifiers encircled by double quotes.

An regular identifier must start with instructions and contain only letters, underscore figures (_), and numbers. The allowed letters and numbers include all Unicode letters and numbers, but Derby doesn't attempt to make sure that the figures in identifiers are valid within the database's locale.

A delimited identifier can contain any figures inside the double quotes. The attaching double quotes aren't area of the identifier they serve simply to mark its beginning and finish. Spaces in the finish of the delimited identifier are minor (cut down). Derby translates two consecutive double quotes inside a delimited identifier as you double quotation mark-that's, the "converted" double quotation mark turns into a character within the delimited identifier.

So, COL# seems to become invalid being an regular identifier due to the #. "COL#" would most likely be valid like a delimited identifier, however i haven't examined this.