36.5. Adding and Editing Fields

New fields can be added to tables, and the names of existing fields can be changed. There is no way to change the type of field size, though, unless you delete and re-add it. When a field is created, it will always initially contain NULL values in existing rows of the table.

To add a field, follow these steps:

1.
On the module's main page, click on the icon for the database that contains the table. Then click on the icon for the table itself. This will bring you to a page listing the names, types, and sizes of existing fields, as shown in Figure 36.3.

Figure 36.3. The table editing page.


2.
Select a type for the new field from the menu next to the Add field of type button. When clicked, your browser will display the field creation form for entering the rest of the details.

3.
Choose a name for this field that consists of only letters, numbers, and the _ character, and enter it into the Field name text box. No two fields in the same table can have the same name.

4.
For a char or varchar field, enter the maximum number of characters that it can hold into the Type width text box. For a numeric field, you must instead enter two numbers separated by a comma, like 10,2. The first is the maximum number of digits that a number in this field can store, and the second is the number of digits to the right of the decimal point.

For other field types, the Type width text box does not appear at all.

5.
If you want this field to be able to store multiple values of the same type, select Yes for the Array field? option.

6.
Click Create to have the field added to the table, as long as there were no errors in your input.

Once a field has been created, you can only change its name, unlike in MySQL where its type or size can be modified. This means, however, that there is no risk to the data that it contains. To rename a field in a table, follow these steps:

1.
On the module's main page, click on the icon for the database containing the table, and then on the table icon. This will bring you to the list of fields in the table, an example of which is shown in Figure 36.3.

2.
Click on the name of the field that you want to change.

3.
On the editing form, update the Field name text box with a new name. Naturally, this must follow the same naming rules as apply when creating a field.

4.
Click the Save button to have the change made in the database.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.118.210.133