Databases Reference
In-Depth Information
Changing table structure
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 section 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 will cover the topic of index management.
Adding a column
Suppose that we need a new column to store a topic's language and, by default, the
topic on which we keep data are written in English. We call the column language ,
which will contain code composed of two characters ( en by default).
In the Structure page of the Table view for the topic table, we can find the Add
column dialog. Here, we specify how many new columns we want, and where they
will go.
The positions of the new columns in the table matter only from a developer's point of
view. We usually group the columns logically, so that we can find them more easily
in the list of columns. The exact position of the columns 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 columns (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 column At End of Table . So, we check the corresponding
radio button and click on Go .
Other possible choices would be At Beginning of Table and After (where we
would have to choose from the drop-down menu, the column after which the new
one must go).
We see the familiar panel for entering column's attributes. We fill it in. However, as
we want to enter a default value this time, we do the following two actions:
• Change the Default drop-down menu from None to As defined:
• Enter the default value: en
 
Search WWH ::




Custom Search