Tag Link | [Database_CreateColumn] | Category | Database |
---|---|---|---|
Type | Process | Source Available | Yes |
Support | Synonym | Version | 5.0 |
Change | Unchanged | Data Source | Lasso MySQL |
Output Type | None | Security | Tag |
Implementation | LDML | Sets | Lasso 8.5, Lasso 8.0, Lasso 7.0, Lasso 6.0, Lasso 5.0 |
[Database_CreateColumn] creates a new field in an existing MySQL database table. By calling the [Database_CreateTable] tag and a series of [Database_CreateField] tags a new table can be created entirely in LassoScript.
This tag is certified to work with Lasso MySQL and MySQL data sources. It may also work with third party data sources that support the
This tag requires
The
An optional default value for the field can be specified in the
The field is added to the end of the table by default. The
Key fields can be created by specifying the option
A field can be set to accept NULL values by specifying the
The valid MySQL data types are as follows:
Integers: TINYINT, SMALLINT, MEDIUMINT, INT, BIGINT. Each integer type can also be unsigned as in TINYINT UNSIGNED.
Decimals: FLOAT, DOUBLE, DECIMAL(Length, Precision).
Strings: CHAR(Length), VARCHAR(Length), TINYTEXT, MEDIUMTEXT, TEXT, LONGTEXT.
Binary: CHAR(Length) BINARY, VARCHAR(Length) BINARY, TINYBLOB, MEDIUMBLOB, BLOB, LONGBLOB.
Dates: DATETIME, TIMESTAMP, DATE, TIME, YEAR.
[Database_CreateColumn:
[Database_CreateColumn:
[Database_CreateColumn:
Required Parameters | |
---|---|
-Database | The name of the database to which the field should be added. |
-Table | The name of the table to which the field should be added. |
-Field | The name of the field which should be added. |
-Type | The MySQL type of the field which should be added. |
-NotNull | Specifies that null values should not be allowed in the field. Cannot be used in conjunction with |
Optional Parameters | |
-Default | The default value the field should be set to on new records if no specific value for the field is defined. |
-AutoIncrement | If specified, the field will auto |
-Key | If specified, the field will be set as the primary key for the table. Only one primary key can exist per table. |
-Null | Specifies that null values are allowed in the field. The default. |
-AfterField | The name of the field after which this field should be created. Defaults to adding the field to the end of the table. Cannot be used in conjunction with |
-BeforeFirst | Specifies that the field should be inserted before the first field in the table. Cannot be used in conjunction with |
To create a new field in a Lasso MySQL table:
Use the [Database_CreateColumn] tag. The following code creates a new field in the MyPreferences table of the Site database. The new field is named CreationDate and is set to data type DATETIME.
[Database_CreateColumn: