41.5 Fields
A Column is a set of data values of a particular type, one for each row of the table. The Columns provide the structure according to which the rows are composed. The term Field is often used interchangeably with Column, although many consider it more correct to use field (or field value) to refer specifically to the single item that exists at the intersection between one row and one column.
Creating a Field
To create a Field:
- open the ''Server Object List'' (chap. 16);
- expand the ''Tables'' node relating the database which contains the table you want to create the field in;
- double click on the table name;
- click on the ''Fields'' Tab of the ''Table Editor'' (sec. 41.4);
- click on the ''Add Field'' button (or right click and select the ''Add Field'' item from the popup menu);
- use the ''Field Editor'' (sec. 41.5.1).
Editing a Field
To edit a Field:
- open the ''Server Object List'' (chap. 16);
- expand the ''Tables'' node relating the database which contains the table which contains the field you want to edit;
- double click on the table name;
- click on the ''Fields'' Tab of the ''Table Editor'' (sec. 41.4);
- in the fields' grid select the row relating the field you want to edit;
- click on ''Edit selected Field'' button (or double click or right click and select the ''Edit Field'' item from the popup menu);
- use the ''Field Editor'' (sec. 41.5.1).
Dropping a Field
To drop a Field:
- open the ''Server Object List'' (chap. 16);
- expand the ''Tables'' node relating the database which contains the table you want to drop the field from;
- double click on the table name;
- click on the ''Fields'' Tab of the ''Table Editor'' (sec. 41.4);
- in the fields' grid select the row relating the field you want to drop;
- click on the ''Drop selected Field'' button (or right click and select the ''Drop Field'' item from the popup menu);
- confirm the requested operation.
Multi-Drop of Fields
To drop a set a fields of a table:
- open the ''Server Object List'' (chap. 16);
- expand the table node relating the database which contains the table you want to drop the fields from;
- right click on the ''Fields'' node and select the ''Multi-Drop of Fields'' item from the popup menu;
- use the ''Multi-Drop Wizard'' (chap. 26).
41.5.1 Field Editor
The
Field Editor allows you to create and edit table fields. The caption of the Editor reports if you are adding or editing a field.
The ''Editor'' (Fig. 41.35) can be opened from the Create Table Wizard, from the Table Editor or using the popup menu of the Server Objects List (see the introduction of the sec. 41.5).
See Also:
Figure 41.35:
The Field Editor.
|
|
41.5.1.1 Name and Type
Set the field name and choose the field data type (Fig.
41.36).
Figure 41.36:
Field name and type.
|
|
41.5.1.2 Properties
You may set some field flags like unsigned or zerofill (Fig.
41.37).
Figure 41.37:
Field properties.
|
|
41.5.1.3 Dimension
Set the dimension for the field from the ''Field Dimension'' frame.
This frame changes according to the data type of the field; you may click on the information icon at the right to get information about the field data type.
For example, for an INT field the ''Field Dimension'' frame is like that in Fig.
41.38.
Figure 41.38:
Field dimension (INT data type example).
|
|
For a DECIMAL data type, the frame is like that in Fig. 41.39.
Figure 41.39:
Field dimension (DECIMAL data type example).
|
|
For a TEXT data type, the frame is like that in Fig. 41.40.
Figure 41.40:
Field dimension (TEXT data type example)
|
|
For a LONGBLOB data type, the frame is like that in Fig. 41.41.
Figure 41.41:
Field dimension (LONGBLOB data type example).
|
|
For a LONGTEXT data type, the frame is like that in Fig. 41.42.
Figure 41.42:
Field dimension (LONGTEXT data type example).
|
|
41.5.1.4 Values
The ''Field Values'' frame (Fig.
41.43 and
41.44) allows you to set:
- the list of values for an ENUM or SET data type;
- the default value for a field.
Note: you can manually write the comma separated list of values for an ENUM or SET data type (e.g. 'value_1','value_2',...,'value_n') or you can click on button at the right and use the ''Value List Editor'' (Fig.
41.5.1).
Figure 41.43:
Field Value.
|
|
Figure 41.44:
Default value for a TIMESTAMP field.
|
|
41.5.1.4.1 Value List Editor
The
Value List Editor (Fig.
41.45) allows you to set the values for an ENUM or SET data type.
Write a value and click on the ''Add value'' button; when done click on the ''Ok'' button.
Figure 41.45:
Value List Editor.
|
|
41.5.1.5 Charset
The ''Field Charset'' frame (Fig.
41.46) allows you to set the field charset and collation for the CHAR, VARCHAR and TEXT data type.
See Also:
- 6.3.1: Client, Results and Connection Charset and Collation
- 27.7: Server Charset and Collation
- 37.1: Database Charset and Collation
- 41.2.2: Table Charset and Collation
MySQL
TM chooses the column character set and collation in the following manner:
- If both CHARACTER SET X and COLLATE Y were specified, then character set X and collation Y are used.
- If CHARACTER SET X was specified without COLLATE, then character set X and its default collation are used.
- Otherwise, the table character set and collation are used.
Note: if you leave the ''Default'' value, the charset and collation clauses are not included in the create or edit field query and the charset and collation for that field are the charset and collation of the table the field belongs to.
Note 2: your server version should be higher than 4.0 to set charset and collation.
Figure 41.46:
Field Charset and Collation.
|
|
41.5.1.6 Insert Options
The ''Insert Options'' frame (Fig.
41.47) allows you to set in which position (first, last, or after of) the field has to be inserted.
Figure 41.47:
Advanced Insert Options.
|
|
Copyright © 2007 - 2009 HoneySoftware - All Rights Reserved
Submit feedback on this topic.