[Database_ChangeColumn] changes an existing field in a MySQL database table. The syntax is very similar to [Database_CreateColumn] with the addition of an -Original parameter that specifies the name of the field whose definition is being changed.
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 -SQL command tag.
This tag requires a -Database and a -Table parameters that specify in which database and table the field should be changed. The database and table must already exist and the current user must have permission to execute -SQL actions. The database and table must be specified using the proper capatilization in order for this tag to work properly.
The -Original parameter specifies the name of the field which should be modified. The remainder of the parameters must be specified in order to fully define the new characteristics of the field. Any parameters which are not specified will be reset to their default.
The -Field parameter specifies the new name of the field to be changed and the -Type parameter specifies the type for the field. The -Type parameter must be set to a valid MySQL type. The valid types are summarized below.
An optional default value for the field can be specified in the -Default parameter. If the field is not set to an explicit value when a new record is added then this value will be used for the field.
The field is modified in place by default. The -BeforeFirst parameter can be optionally specified to move the field to the start of the table. Or, the -AfterField parameter can be specified to name an existing field after which the field should be moved.
Key fields can be created by specifying the option -Key parameter. In general only one key field can be created. Similarly, an integer field can be set to auto increment using the -AutoIncrement parameter. In general only one field can be set to auto increment.
A field can be set to accept NULL values by specifying the -Null parameter or can be set not to accept NULL values by specifying the -NotNull parameter.
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_ChangeColumn: -Database='Database Name',
-Table='Table Name',
-Original='Original Field Name',
-Field='Field Name',
-Type='MySQL Type',
-Default='Default Value']
[Database_ChangeColumn: -Database='Database Name',
-Table='Table Name',
-Original='Original Field Name',
-Field='Field Name',
-Type='MySQL Type',
-BeforeFirst,
-Null]
[Database_ChangeColumn: -Database='Database Name',
-Table='Table Name',
-Original='Original Field Name',
-Field='Field Name',
-Type='MySQL Type',
-AfterField='Field Name',
-Key,
-AutoIncrement,
-NotNull]
Use the [Database_ChangeColumn] tag. The following code changes the CreationDate field in the MyPreferences table of the Site database by adding the -NotNull parameter. Notice that the name and type of the field are stated again in full.
[Database_ChangeColumn: -Database='Site',
-Table='MyPreferences',
-Original='CreationDate',
-Field='CreationDate',
-Type='DATETIME',
-NonNull]
Tag Link | [Database_ChangeColumn] | Category | Database |
---|---|---|---|
Type | Process | Data Source | MySQL |
Support | Synonym | Version | 5.0 |
Output Type | None | Security | Tag |
Implementation | Sets | Lasso 5.0 |
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft