Chapter 3: Make APPX Files Available to SQL
SQL Name Rules and Reserved Words
A table, column or view name can be written plain, the way ASQL writes them, or inside double quotes.
Plain names:
- start with a letter or an underscore,
- contain only letters, digits and underscores,
- are at most 32 characters long,
- can't be one of the reserved words listed below, and
- ignore capitals:
Region_Labelandregion_labelare the same column.
A longer name fails with -20248 Identifier too long., quoted or not. See What Works Better in Later Releases for a later configuration with longer names.
These names were tried on this edition's gateway:
| Name | Result |
|---|---|
name_2, _name, RegionLabel | Accepted. |
2name | -20003 Syntax error. "2name" works. |
region-label, region label | -20003 Syntax error. Both work in double quotes. |
A name containing $, #, @ or . | -20003 Syntax error. It works in double quotes. |
| A name of 33 characters or more | -20248 Identifier too long. |
A table name that starts with a digit, such as 0SA_DMO_FILE | -20003 Syntax error. It works in double quotes. |
A name in double quotes can use any characters and can be a reserved word, but it keeps its exact capitals, and every statement has to quote it the same way. A column created as "suffix" is found by "suffix" but not by "SUFFIX", which fails with -20006 Column not found/specified. A plain name is read in lower case, so quote in lower case, the way ASQL writes names. Renaming a column is usually simpler than quoting it; see Rename a column before it is created.
Reserved words
The gateway refuses two kinds of words as plain names, and they behave differently:
- Refused everywhere, with
-20003 Syntax error. These are part of SQL itself, such as NUMBER, TYPE, DATE, ORDER and FILE. A column with one of these names has to be in double quotes in every statement that uses it, including every query, report and spreadsheet. Rename the column instead. - Refused only as a new name, with
-20049 Keyword used for a name. These fail where a table or view is created, but queries can use them without quotes. Quoting the name once in theCREATE TABLEstatement, in lower case, is enough.
This edition's gateway uses the Dharma 9.01 SQL server. It refuses every word in Dharma's own reserved word table except RANGE, including function names such as SUFFIX, PREFIX and LENGTH. The 5.5.3, 5.5.4 and 6.2.1 gateways use Dharma 14.01, which accepts most function names but refuses a few words this one accepts, such as DAY, BOTH and LEADING. Check the list again before moving to a later release. See What Works Better in Later Releases.
ASQL's Reserved Keywords list, shown in expert mode, is only a guide. It combines the ODBC standard's keyword list, ASQL's own list and the driver's list, so it includes many words this gateway accepts, such as DAY, LEVEL and POSITION. The tables below show what this edition's gateway refused when each word was tried as a column name.
Refused everywhere: 210 words. Without double quotes these fail in any statement, queries included, with -20003 Syntax error.
| Starts with | Words |
|---|---|
| A | ADD, AFTER, ALL, ALTER, AND, ANY, AS, ASC, AVG |
| B | BEFORE, BETWEEN, BIGINT, BINARY, BIT, BY |
| C | CALL, CASCADE, CASE, CAST, CHAR, CHARACTER, CHECK, CLOSE, CLUSTERED, COALESCE, COLGROUP, COLLATE, COLUMN, COMMIT, COMPRESS, CONNECT, CONSTRAINT, CONTAINS, COUNT, CREATE, CROSS, CURRENT, CURSOR |
| D | DATABASE, DATAPAGES, DATE, DBA, DEC, DECIMAL, DECLARE, DEFAULT, DEFINITION, DELETE, DESC, DISTINCT, DOUBLE, DROP |
| E | EACH, ELSE, END, ESCAPE, EXCLUSIVE, EXECUTE, EXISTS |
| F | FETCH, FILE, FLOAT, FOR, FOREIGN, FROM, FULL |
| G | GRANT, GROUP |
| H | HASH, HAVING |
| I | IDENTIFIED, IN, INDEX, INDEXPAGES, INDICATOR, INNER, INOUT, INSERT, INT, INTEGER, INTERSECT, INTO, IS |
| J | JOIN |
| K | KEY |
| L | LEFT, LIKE, LINK, LOCK, LOG, LONG, LVARBINARY, LVARCHAR |
| M | MAX, METADATA_ONLY, MIN, MINUS, MODE, MODIFY, MONEY |
| N | NATIONAL, NATURAL, NCHAR, NEWROW, NOCOMPRESS, NOT, NOWAIT, NULL, NULLIF, NUMBER, NUMERIC |
| O | OF, OLDROW, ON, OPEN, OPTION, OR, ORDER, OUT, OUTER |
| P | PCTFREE, PRECISION, PRIMARY, PRIVILEGES, PROCEDURE, PUBLIC |
| R | RAW, REAL, REFERENCES, REFERENCING, RENAME, RESOURCE, RESTRICT, RESULT, RETURN, REVOKE, RIGHT, ROLLBACK, ROW, ROWID, ROWNUM |
| S | SELECT, SET, SHARE, SIZE, SMALLINT, SOME, SPACE, SQL_BIGINT, SQL_BINARY, SQL_BIT, SQL_CHAR, SQL_DATE, SQL_DECIMAL, SQL_DOUBLE, SQL_FLOAT, SQL_INTEGER, SQL_LONGVARBINARY, SQL_LONGVARCHAR, SQL_NUMERIC, SQL_REAL, SQL_SMALLINT, SQL_TIME, SQL_TIMESTAMP, SQL_TINYINT, SQL_TSI_DAY, SQL_TSI_FRAC_SECOND, SQL_TSI_HOUR, SQL_TSI_MINUTE, SQL_TSI_MONTH, SQL_TSI_QUARTER, SQL_TSI_SECOND, SQL_TSI_WEEK, SQL_TSI_YEAR, SQL_VARBINARY, SQL_VARCHAR, STATEMENT, STATISTICS, STORAGE_ATTRIBUTES, STORAGE_MANAGER, STORE_IN_DHARMA, SUM, SYNONYM, SYSDATE, SYSTIME, SYSTIMESTAMP |
| T | TABLE, THEN, TIME, TIMESTAMP, TINYINT, TO, TRANSACTION, TRIGGER, TYPE |
| U | UID, UNION, UNIQUE, UPDATE, USER, USING |
| V | VALUES, VARBINARY, VARCHAR, VARYING, VIEW |
| W | WHEN, WHERE, WITH, WORK |
Refused only as a new name: 134 words. Without double quotes these fail when a table or view is created, with -20049 Keyword used for a name. Queries can use them without quotes.
| Starts with | Words |
|---|---|
| A | A, ABS, ACOS, ADD_MONTHS, AN, ARRAY, ASCII, ASIN, ATAN, ATAN2 |
| B | BEGIN, BIND, BINDING |
| C | CEILING, CHARACTER_LENGTH, CHARTOROWID, CHAR_LENGTH, CHR, CLEANUP, COMPLEX, CONCAT, CONTINUE, CONVERT, COS, CURDATE, CURTIME, CVAR |
| D | DAYNAME, DAYOFMONTH, DAYOFWEEK, DAYOFYEAR, DB_NAME, DECLARATION, DECODE, DEGREES, DESCRIBE, DESCRIPTOR, DHTYPE, DIFFERENCE |
| E | EXEC, EXIT, EXP, EXPLICIT |
| F | FIELD, FLOOR, FOUND |
| G | GO, GOTO, GREATEST |
| H | HOUR |
| I | IFNULL, IMMEDIATE, INITCAP, INPUT, INSTR, INTERFACE |
| L | LAST_DAY, LCASE, LEAST, LENGTH, LIST, LOCATE, LOG10, LOWER, LPAD, LTRIM |
| M | MAIN, MINUTE, MOD, MONTH, MONTHNAME, MONTHS_BETWEEN |
| N | NEXT_DAY, NOW, NULLVALUE, NVL |
| O | OBJECT_ID, ODBCINFO, ODBC_CONVERT, OUTPUT |
| P | PI, POWER, PREFIX, PREPARE |
| Q | QUARTER |
| R | RADIANS, RAND, RECORD, REPEAT, REPLACE, ROWIDTOCHAR, RPAD, RTRIM |
| S | SEARCHED_CASE, SECOND, SECTION, SERVICE, SHORT, SIGN, SIMPLE_CASE, SIN, SOUNDEX, SQL, SQLERROR, SQLWARNING, SQRT, START, STOP, SUBSTR, SUBSTRING, SUFFIX, SUSER_NAME |
| T | TAN, TIMEOUT, TIMESTAMPADD, TIMESTAMPDIFF, TO_CHAR, TO_DATE, TO_NUMBER, TO_TIME, TO_TIMESTAMP, TPE, TRANSLATE |
| U | UCASE, UNSIGNED, UPPER, USER_ID, USER_NAME, UUID |
| V | VARIABLES, VERSION |
| W | WEEK, WHENEVER |
| Y | YEAR |