-
-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test(mtr): add alter_table_v1.result(#497)
- Loading branch information
1 parent
02cb94c
commit 0663837
Showing
1 changed file
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,151 @@ | ||
# | ||
# Test of alter table | ||
# | ||
create table t1 (bandID MEDIUMINT NOT NULL PRIMARY KEY, payoutID SMALLINT NOT NULL); | ||
insert into t1 (bandID,payoutID) VALUES (1,6),(2,6),(3,4),(4,9),(5,10),(6,1),(7,12),(8,12); | ||
alter table t1 add column new_col int, order by payoutid,bandid; | ||
select * from t1; | ||
bandID payoutID new_col | ||
6 1 NULL | ||
3 4 NULL | ||
1 6 NULL | ||
2 6 NULL | ||
4 9 NULL | ||
5 10 NULL | ||
7 12 NULL | ||
8 12 NULL | ||
alter table t1 order by bandid,payoutid; | ||
select * from t1; | ||
bandID payoutID new_col | ||
1 6 NULL | ||
2 6 NULL | ||
3 4 NULL | ||
4 9 NULL | ||
5 10 NULL | ||
6 1 NULL | ||
7 12 NULL | ||
8 12 NULL | ||
drop table t1; | ||
# | ||
# Test of ALTER TABLE ... ORDER BY | ||
# | ||
create table t1 (n int); | ||
insert into t1 values(9),(3),(12),(10); | ||
alter table t1 order by n; | ||
select * from t1; | ||
n | ||
3 | ||
9 | ||
10 | ||
12 | ||
drop table t1; | ||
# | ||
# Drop and add an auto_increment column | ||
# | ||
create table t1 (i int not null auto_increment primary key); | ||
insert into t1 values (null),(null),(null),(null); | ||
select * from t1; | ||
i | ||
1 | ||
2 | ||
3 | ||
4 | ||
drop table t1; | ||
# | ||
# 'alter table t1 rename mysqltest.t1' silently drops mysqltest.t1 | ||
# if it exists | ||
# | ||
create table t1 (name char(15)); | ||
insert into t1 (name) values ("current"); | ||
create database mysqltest; | ||
create table mysqltest.t1 (name char(15)); | ||
insert into mysqltest.t1 (name) values ("mysqltest"); | ||
select * from t1; | ||
name | ||
current | ||
select * from mysqltest.t1; | ||
name | ||
mysqltest | ||
alter table t1 rename mysqltest.t1; | ||
ERROR 42S01: Table 't1' already exists | ||
select * from t1; | ||
name | ||
current | ||
select * from mysqltest.t1; | ||
name | ||
mysqltest | ||
drop table t1; | ||
drop database mysqltest; | ||
# | ||
# ALTER TABLE ... ENABLE/DISABLE KEYS | ||
# | ||
create table t1 (n1 int not null, n2 int, n3 int, n4 float, | ||
unique(n1), | ||
key (n1, n2, n3, n4), | ||
key (n2, n3, n4, n1), | ||
key (n3, n4, n1, n2), | ||
key (n4, n1, n2, n3))engine=tianmu; | ||
alter table t1 disable keys; | ||
Warnings: | ||
Note 1031 Table storage engine for 't1' doesn't have this option | ||
show keys from t1; | ||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment | ||
t1 0 n1 1 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n1_2 1 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n1_2 2 n2 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n1_2 3 n3 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n1_2 4 n4 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n2 1 n2 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n2 2 n3 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n2 3 n4 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n2 4 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n3 1 n3 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n3 2 n4 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n3 3 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n3 4 n2 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n4 1 n4 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n4 2 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n4 3 n2 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n4 4 n3 NULL NULL NULL NULL YES LSMTREE | ||
insert into t1 values(RAND()*100,RAND()*100,RAND()*10,RAND()*10); | ||
alter table t1 enable keys; | ||
Warnings: | ||
Note 1031 Table storage engine for 't1' doesn't have this option | ||
show keys from t1; | ||
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment | ||
t1 0 n1 1 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n1_2 1 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n1_2 2 n2 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n1_2 3 n3 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n1_2 4 n4 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n2 1 n2 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n2 2 n3 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n2 3 n4 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n2 4 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n3 1 n3 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n3 2 n4 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n3 3 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n3 4 n2 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n4 1 n4 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n4 2 n1 NULL NULL NULL NULL LSMTREE | ||
t1 1 n4 3 n2 NULL NULL NULL NULL YES LSMTREE | ||
t1 1 n4 4 n3 NULL NULL NULL NULL YES LSMTREE | ||
drop table t1; | ||
# | ||
# Alter table and rename | ||
# | ||
create table t1 (i int not null auto_increment primary key)engine=tianmu; | ||
alter table t1 rename t2; | ||
show columns from t2; | ||
Field Type Null Key Default Extra | ||
i int(11) NO PRI NULL auto_increment | ||
drop table t2; | ||
# | ||
# check for valid table names | ||
# | ||
create table t1 (a int); | ||
alter table t1 rename to ``; | ||
ERROR 42000: Incorrect table name '' | ||
rename table t1 to ``; | ||
ERROR 42000: Incorrect table name '' | ||
drop table t1; |