Databases Reference
In-Depth Information
design. Choose the column types you need, explaining the advantages and disad-
vantages of your choices.
2. There are five types for storing temporal data:
DATETIME
,
DATE
,
TIME
,
YEAR
, and
TIMESTAMP
. Explain what each is used for, and give an example of a situation in
which you would choose to use it.
3. You've decided to use the
AUTO_INCREMENT
feature. List the three requirements that
must be met by the column you're applying it to.
4. Why can only one column in a table have the
AUTO_INCREMENT
feature?
5. Using the monitor, create a table with the following statement:
mysql>
CREATE TABLE exercise (field1 INT(3));
Using the
ALTER TABLE
statement, make
field1
the primary key, carrying out any
additional steps you need to make this possible. Add a second column,
field2
, of
type
CHAR(64)
with a
DEFAULT 5
clause. Create an index on a prefix of 10 characters
from
field2
.