mirror of
https://github.com/MariaDB/server.git
synced 2025-12-01 17:39:21 +03:00
Introduced new alter algorithm type called NOCOPY & INSTANT for inplace alter operation. NOCOPY - Algorithm refuses any alter operation that would rebuild the clustered index. It is a subset of INPLACE algorithm. INSTANT - Algorithm allow any alter operation that would modify only meta data. It is a subset of NOCOPY algorithm. Introduce new variable called alter_algorithm. The values are DEFAULT(0), COPY(1), INPLACE(2), NOCOPY(3), INSTANT(4) Message to deprecate old_alter_table variable and make it alias for alter_algorithm variable. alter_algorithm variable for slave is always set to default.
51 lines
1.5 KiB
Plaintext
51 lines
1.5 KiB
Plaintext
CREATE TABLE t1(f1 INT NOT NULL,
|
|
f2 INT NOT NULL,
|
|
f3 INT AS (f2 * f2) VIRTUAL,
|
|
INDEX idx (f2))engine=innodb;
|
|
CREATE TABLE t2(f1 INT NOT NULL, f2 INT NOT NULL,
|
|
f3 VARCHAR(10),
|
|
INDEX(f1))ENGINE=INNODB;
|
|
INSERT INTO t1(f1, f2) VALUES(1, 1);
|
|
select @@alter_algorithm;
|
|
@@alter_algorithm
|
|
NOCOPY
|
|
# Add column at the end of the table
|
|
ALTER TABLE t1 ADD COLUMN f4 char(100) default "BIG WALL";
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
# Change virtual column expression
|
|
ALTER TABLE t1 CHANGE f3 f3 INT AS (f2 * f2) VIRTUAL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
# Add virtual column
|
|
ALTER TABLE t1 ADD COLUMN f5 INT AS (f2) VIRTUAL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
# Rename Column
|
|
ALTER TABLE t1 CHANGE f3 vcol INT AS (f2) VIRTUAL;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
# Rename table
|
|
ALTER TABLE t1 RENAME t3;
|
|
affected rows: 0
|
|
# Drop Virtual Column
|
|
ALTER TABLE t3 DROP COLUMN vcol;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
# Column length varies
|
|
ALTER TABLE t2 CHANGE f3 f3 VARCHAR(20);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SET foreign_key_checks = 0;
|
|
affected rows: 0
|
|
ALTER TABLE t3 ADD FOREIGN KEY `fidx`(f2) REFERENCES t2(f1);
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
SET foreign_key_checks = 1;
|
|
affected rows: 0
|
|
ALTER TABLE t3 DROP FOREIGN KEY `fidx`;
|
|
affected rows: 0
|
|
info: Records: 0 Duplicates: 0 Warnings: 0
|
|
DROP TABLE t3, t2;
|
|
affected rows: 0
|