Oracle 5.0 Reference Manual page 1036

Table of Contents

Advertisement

ALTER TABLE t1 MODIFY b BIGINT NOT NULL;
is an extension to
MODIFY
When you use
CHANGE
attributes that should apply to the new column, other than index attributes such as
or UNIQUE. Attributes present in the original definition but not specified for the new definition are not
carried forward. Suppose that a column
and you modify the column as follows:
'my column'
ALTER TABLE t1 MODIFY col1 BIGINT;
The resulting column will be defined as BIGINT, but will not include the attributes
DEFAULT 1 COMMENT 'my
ALTER TABLE t1 MODIFY col1 BIGINT UNSIGNED DEFAULT 1 COMMENT 'my column';
• When you change a data type using
values to the new type as well as possible.
Warning
This conversion may result in alteration of data. For example, if you shorten
a string column, values may be truncated. To prevent the operation from
succeeding if conversions to the new data type would result in loss of data,
enable strict SQL mode before using
"Server SQL
• To add a column at a specific position within a table row, use
default is to add the column last. You can also use
operations to reorder columns within a table.
ALTER ... SET DEFAULT
column or remove the old default value, respectively. If the old default is removed and the column
can be NULL, the new default is NULL. If the column cannot be NULL, MySQL assigns a default value
as described in
Section 11.1.7, "Data Type Default
removes an index. This is a MySQL extension to standard SQL. See
DROP INDEX
Section 13.1.15,
"DROP INDEX
FROM
tbl_name.
• If columns are dropped from a table, the columns are also removed from any index of which they
are a part. If all columns that make up an index are dropped, the index is dropped as well. If you use
or
CHANGE
MODIFY
column length is less than the index length, MySQL shortens the index automatically.
• If a table contains only one column, the column cannot be dropped. If what you intend is to remove
the table, use
DROP TABLE
DROP PRIMARY KEY
If you add a
UNIQUE INDEX
index to permit detection of duplicate keys as early as possible.
• Some storage engines permit you to specify an index type when creating an index. The syntax for
the
specifier is
index_type
"CREATE INDEX
Syntax". Before MySQL 5.0.60,
list. As of 5.0.60, the preferred position is after the column list. Support for use of the option before
the column list will be removed in a future MySQL release.
ALTER TABLE
for Oracle compatibility.
ALTER TABLE
or MODIFY,
column_definition
col1
column'. To retain them, the statement should be:
CHANGE
Modes").
or
ALTER ... DROP DEFAULT
Syntax". If you are unsure of the index name, use
to shorten a column for which an index exists on the column, and the resulting
instead.
drops the primary key. If there is no primary key, an error occurs.
or
PRIMARY KEY
type_name. For details about USING, see
USING
1016
Syntax
must include the data type and all
is defined as
INT UNSIGNED DEFAULT 1 COMMENT
or MODIFY, MySQL tries to convert existing column
ALTER TABLE
FIRST
and
FIRST
AFTER
specify a new default value for a
Values".
to a table, MySQL stores it before any nonunique
can be given only before the index column
USING
PRIMARY KEY
UNSIGNED
(see
Section 5.1.7,
or
col_name. The
AFTER
in
or
CHANGE
MODIFY
SHOW INDEX
Section 13.1.8,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents