KNOWLEDGE BASE
Log In    |    Knowledge Base    |    4D Home
Tech Tip: Using VARCHAR in SQL to create an Alpha or Text field
PRODUCT: 4D Developer | VERSION: 11 | PLATFORM: Mac & Win
Published On: January 3, 2008

You can use the SQL language to add Text and Alpha fields to your tables.

To create an Alpha field, specify the field's length as follows:

`The following code will add a field, Field_4, of type Alpha (length 20 characters)
`to Table_1
Begin SQL
   ALTER TABLE Table_1
   ADD Field_4 VARCHAR(20)

End SQL


To create a text field, do not specify a field length as follows:

`The following code will add a field, Field_4, of type Text to Table_1. The only
`difference between this and the previous example is that no size is declared after
`VARCHAR.
Begin SQL
   ALTER TABLE Table_1
   ADD Field_4 VARCHAR

END SQL


For a complete list of the data type mappings in 4D v11 SQL refer to page 217 of the 4D v11 SQL "Upgrade" document (4D_v11_Upgrade.pdf) which you can download from:

http://www.4d.com/support/documentation.html