Database Reference
In-Depth Information
Changing Table Structures
When developing an application, requirements about data structure often change
because of new or modified needs. Developers must accommodate these changes
through judicious table structure editing. This chapter explores the subject of
changing the structure of tables. Specifically, it shows how to add a column to an
existing table and edit the attributes of a column. We then build on these notions
to introduce more specialized column types, and to explain their handling through
phpMyAdmin. Finally, we cover the topic of index management.
Adding a field
Suppose that we need a new field to store a book's language and, by default, the
topics on which we keep data are written in English. We can call the ield language ,
which will contain code composed of two characters ( en by default).
In the Structure subpage of the Table view for the book table, we can find the
Add field dialog. Here, we specify how many new fields we want, and where
they will go.
The positions of the new fields in the table matter only from a developer's point of
view. We usually group the fields logically, so that we can find them more easily in
the list of fields. The exact position of the fields will not play a role in the intended
results (output from the queries), as these results can be adjusted regardless of the
table structure. Usually, the most important fields (including the keys) are located at
the beginning of the table. However, it is a matter of personal preference.
We want to put the new field At End of Table . So, we check the corresponding radio
button and click on Go .
Search WWH ::




Custom Search