Database Reference
In-Depth Information
Figure 8.5
The correctly updated webpage table.
thing that we have the ALTER command. The general format of an ALTER query is as fol-
lows:
ALTER TABLE tablename
commandtype columnname parameters
The ALTER TABLE command can do several things, depending on what you type in the
commandtype position. Commandtype can be one of the following:
ADD adds a new property or column to the table.
RENAME changes the name of the table.
CHANGE changes the name of a column and its datatype.
MODIFY, changes the datatype of a column.
DROP removes the column from the table completely.
The next few sections will demonstrate these different types of ALTER query with our
visitorbook table. To remind ourselves of this table, run the following:
DESCRIBE visitorbook
Figure 8.6 shows the current format of the visitorbook table. As we created this in a rush
and not in our chapter on the design of databases, we made a few mistakes. We will change
some of the columns and add an extra one using ALTER.
As a final reminder, Figure 8.7 shows the current content of the table, after selecting
everything from it.
ALTER TABLE ADD
The ALTER TABLE ADD query has the following basic format:
ALTER TABLE tablename
ADD
columnname datatype
Search WWH ::




Custom Search