KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Guidelines for SQL compatible field names
PRODUCT: 4D | VERSION: 11 | PLATFORM: Mac & Win
Published On: February 18, 2009

Here are the guidelines for naming a field:

- Field names cannot begin with a number
- Field names cannot include any spaces
- Field names cannot begin with an underscore
- Field names cannot have the same name as a SQL function or reserved word
- Field names cannot have same name as a 4D Command

To test a field name's validity, go to the Structure Editor and select a field. In the Inspector look at the bottom-most box labeled "SQL". If there is an error listed in that box then the field name needs to be changed. For example, see the following image:



In the image above, the '[Table_1]YEAR' field is selected in the strucuture editor window and the Inspector is visible. At the bottom of the Inspector window it displays "[!] SQL reserved word." - This is because the field selected (YEAR) is in fact the same name as a SQL function. To correct this, rename the field to a non-reserved word.

Commented by Tim Penner on December 4, 2009 at 10:48 AM
Using a "SQL Command" should also be avoided when naming fields; here is a list of the SQL Commands: http://4d.com/docs/QLU/QLU00003.HTM
Commented by Cheryl Michels on April 21, 2009 at 10:57 AM
In addition, SQL Field Names cannot include #, /, %, (, ), : , period. I am using Regex_Substitution to substitute in these cases.
Commented by Charlie Vass on February 18, 2009 at 10:22 AM
This also applies to Table names.