1
drop database if exists hualong;
2
create database hualong;
4
drop table if exists r1;
5
drop table if exists r2;
6
create table hualong.r1(c1 int not null primary key, c2 int);
7
create table hualong.r2(a int not null primary key , b int);
9
ERROR 42S01: Table 'r2' already exists
10
alter table r1 rename to r2;
11
ERROR 42S01: Table 'r2' already exists
12
rename table r1 to r3, r2 to r3;
13
ERROR 42S01: Table 'r3' already exists
14
rename table r1 to r3, r1 to r3;
15
ERROR 42S01: Table 'r3' already exists
16
rename table r1 to r3, r1 to r4;
17
ERROR HY000: File not exist
19
ERROR 42S01: Table 'r1' already exists
20
rename table xx to a.xxx;
21
ERROR 42000: Unknown database 'a'
22
rename table r1 to table1, table1 to r1;
23
rename table r1 to r3, r2 to r1;
25
ERROR 42S01: Table 'r3' already exists
26
drop database if exists hualong2;
27
create database hualong2;
28
rename table hualong.r1 to hualong2.r1;
29
show tables from hualong;
32
show tables from hualong2;
35
create index idx1 on hualong.r3(c1);
36
rename table hualong.r3 to hualong2.r2;
37
show tables from hualong;
39
show tables from hualong2;
43
show index from hualong2.r2;
44
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
45
r2 0 PRIMARY 1 c1 A NULL NULL NULL BTREE available YES NULL
46
r2 1 idx1 1 c1 A NULL NULL NULL BTREE available YES NULL
47
rename table hualong2.r2 to hualong.r2;
48
show index from hualong.r2;
49
Table Non_unique Key_name Seq_in_index Column_name Collation Cardinality Sub_part Packed Null Index_type Comment Index_comment Visible Expression
50
r2 0 PRIMARY 1 c1 A NULL NULL NULL BTREE available YES NULL
51
r2 1 idx1 1 c1 A NULL NULL NULL BTREE available YES NULL
52
show tables from hualong;
55
rename table hualong2.r1 to hualong.r1;
56
rename table r1 to tmp, tmp to r1, r2 to tmp;
57
show tables from hualong;
61
drop table hualong.r1, hualong.tmp;
63
drop database hualong2;