Oracle 5.0 Reference Manual page 1038

Table of Contents

Advertisement

accepts
specification.
supports the use of
InnoDB
ALTER TABLE
tbl_name
For more information, see
• You cannot add a foreign key and drop a foreign key in separate clauses of a single
statement. You must use separate statements.
For an
table that is created with its own tablespace in an
InnoDB
discarded and imported. To discard the
ALTER TABLE
tbl_name
This deletes the current
table while the tablespace file is discarded results in an error.
To import the backup
this statement:
ALTER TABLE
tbl_name
The tablespace file must have been created on the server into which it is imported later.
See
Section 14.2.1.1, "Using Per-Table
• To change the table default character set and all character columns (CHAR, VARCHAR, TEXT) to a
new character set, use a statement like this:
ALTER TABLE
tbl_name
For a column that has a data type of
will change the data type as necessary to ensure that the new column is long enough to store
SET
as many characters as the original column. For example, a
which store the byte-length of values in the column, up to a maximum of 65,535. For a
column, each character requires a single byte, so the column can store up to 65,535 characters.
If the column is converted to utf8, each character might require up to 3 bytes, for a maximum
possible length of 3 × 65,535 = 196,605 bytes. That length will not fit in a
bytes, so MySQL will convert the data type to MEDIUMTEXT, which is the smallest string type for
which the length bytes can record a value of 196,605. Similarly, a
converted to MEDIUMTEXT.
To avoid data type changes of the type just described, do not use
Instead, use
MODIFY
ALTER TABLE t MODIFY latin1_text_col TEXT CHARACTER SET utf8;
ALTER TABLE t MODIFY latin1_varchar_col VARCHAR(M) CHARACTER SET utf8;
If you specify
CONVERT TO CHARACTER SET
converted to their corresponding binary string types (BINARY, VARBINARY, BLOB). This means that
the columns no longer will have a character set and a subsequent
apply to them.
If
is DEFAULT, the database character set is used.
charset_name
Warning
The
sets. This is not what you want if you have a column in one character set
(like latin1) but the stored values actually use some other, incompatible
ALTER TABLE
clauses defined as part of a separate
REFERENCES
ALTER TABLE
DROP FOREIGN KEY fk_symbol;
Section 14.2.3.4,
.ibd
DISCARD TABLESPACE;
file, so be sure that you have a backup first. Attempting to access the
.ibd
file back into the table, copy it into the database directory, and then issue
.ibd
IMPORT TABLESPACE;
Tablespaces".
CONVERT TO CHARACTER SET charset_name;
VARCHAR
to change individual columns. For example:
operation converts column values between the character
CONVERT TO
1018
Syntax
to drop foreign keys:
"InnoDB
and
FOREIGN KEY
file, use this statement:
or one of the
types,
TEXT
column has two length bytes,
TEXT
VARCHAR
CONVERT TO CHARACTER
binary, the CHAR, VARCHAR, and
CONVERT TO
FOREIGN KEY
Constraints".
ALTER TABLE
file, that file can be
.ibd
CONVERT TO CHARACTER
latin1 TEXT
column's length
TEXT
column might be
columns are
TEXT
operation will not
SET.

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents