Oracle 5.0 Reference Manual page 1039

Table of Contents

Advertisement

To change only the default character set for a table, use this statement:
ALTER TABLE
The word
do not specify the character set for columns that you add to a table later (for example, with
TABLE ... ADD
With the
mysql_info()
TABLE, and (when
values. See
13.1.4.1.
ALTER TABLE
Begin with a table
CREATE TABLE t1 (a INTEGER,b CHAR(10));
To rename the table from
ALTER TABLE t1 RENAME t2;
To change column
change column
ALTER TABLE t2 MODIFY a TINYINT NOT NULL, CHANGE b c CHAR(20);
To add a new
ALTER TABLE t2 ADD d TIMESTAMP;
To add an index on column
ALTER TABLE t2 ADD INDEX (d), ADD UNIQUE (a);
To remove column c:
ALTER TABLE t2 DROP COLUMN c;
To add a new
ALTER TABLE t2 ADD c INT UNSIGNED NOT NULL AUTO_INCREMENT,
ADD PRIMARY KEY (c);
Note that we indexed
and also that we declare
When you add an
automatically. For
INSERT_ID=value
See
Section 5.1.4, "Server System
With
MyISAM
affected. If you drop an
the numbers are resequenced beginning with 1.
ALTER TABLE
character set (like utf8). In this case, you have to do the following for each
such column:
ALTER TABLE t1 CHANGE c1 c1 BLOB;
ALTER TABLE t1 CHANGE c1 c1 TEXT CHARACTER SET utf8;
The reason this works is that there is no conversion when you convert to or
from
columns.
BLOB
tbl_name
DEFAULT CHARACTER SET charset_name;
is optional. The default character set is the character set that is used if you
DEFAULT
column).
C API function, you can find out how many rows were copied by
is used) how many rows were deleted due to duplication of unique key
IGNORE
Section 20.6.6.35,
"mysql_info()".
Examples
that is created as shown here:
t1
to t2:
t1
from
a
INTEGER
from
to
b
CHAR(10)
column named d:
TIMESTAMP
and a
d
integer column named c:
AUTO_INCREMENT
(as a
c
PRIMARY
as
c
NOT NULL
AUTO_INCREMENT
tables, you can set the first sequence number by executing
MyISAM
before
ALTER TABLE
tables, if you do not change the
AUTO_INCREMENT
Syntax
to
TINYINT NOT NULL
as well as renaming it from
CHAR(20)
index on column a:
UNIQUE
KEY) because
AUTO_INCREMENT
because primary key columns cannot be NULL.
column, column values are filled in with sequence numbers
or by using the
Variables".
AUTO_INCREMENT
column and then add another
1019
(leaving the name the same), and to
to c:
b
columns must be indexed,
AUTO_INCREMENT=value
column, the sequence number is not
AUTO_INCREMENT
ALTER
ALTER
SET
table option.
column,

Advertisement

Table of Contents
loading

This manual is also suitable for:

Mysql 5.0

Table of Contents