mark some file to been opensource for ce-farm
This commit is contained in:
209
tools/deploy/mysql_test/test_suite/delete/t/delete.test
Normal file
209
tools/deploy/mysql_test/test_suite/delete/t/delete.test
Normal file
@ -0,0 +1,209 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
# owner: yuchen.wyc
|
||||
# owner group: sql1
|
||||
# 测试delete stmt
|
||||
# tags: delete,dml
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t_part, t_single;
|
||||
--enable_warnings
|
||||
--disable_warnings
|
||||
drop table if exists t2;
|
||||
--enable_warnings
|
||||
--disable_warnings
|
||||
drop table if exists t3;
|
||||
--enable_warnings
|
||||
--disable_warnings
|
||||
drop table if exists t4;
|
||||
--enable_warnings
|
||||
--result_format 4
|
||||
#--explain_protocol 2
|
||||
|
||||
#single column rowkey
|
||||
create table t1(a int primary key, b int);
|
||||
|
||||
insert into t1 values(1,0),(2,0),(3,0);
|
||||
delete from t1;
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1,0),(2,0),(3,0);
|
||||
delete from t1 where a = 1;
|
||||
delete from t1 where a = 2;
|
||||
delete from t1 where a = 3;
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1,0),(2,0),(3,0);
|
||||
delete from t1 where a=1;
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1,0);
|
||||
replace into t1 values(2,0),(3,0);
|
||||
delete from t1 where a=1 or a=2 or a=3;
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1,0),(2,0);
|
||||
delete from t1 where a=1;
|
||||
delete from t1 where a=2;
|
||||
delete from t1 where a=3;
|
||||
select * from t1;
|
||||
|
||||
drop table t1;
|
||||
|
||||
create table t_part (c1 bigint primary key, c2 bigint) partition by hash(c1) partitions 2;
|
||||
create table t_single(c1 int);
|
||||
insert into t_part(c1) values(1231346464513131);
|
||||
insert into t_part values(1, 2), (3, 1);
|
||||
insert into t_part values(2, 3), (4, 3);
|
||||
insert into t_part partition(p0, p1) values(5, 6);
|
||||
insert into t_part values('6', '6'), ('8', '8');
|
||||
delete from t_part where c1 in (select c1 from t_single);
|
||||
select * from t_part;
|
||||
drop table t_part, t_single;
|
||||
|
||||
# multi-column rowkey
|
||||
create table t2 (p1 int, p2 int, p3 int, p4 int, primary key(p1,p2,p3));
|
||||
|
||||
insert into t2 values(1,1,1,0),(2,2,2,0),(3,3,3,0),(4,4,4,0),(5,4,4,0),(6,4,4,0),(7,4,6,0),(8,4,6,0),(9,4,6,0),(10,4,6,0),(11,4,6,0),(12,4,6,0), (13,4,6,0);
|
||||
|
||||
delete from t2 where p1 = 1;
|
||||
|
||||
--disable_query_log
|
||||
--let $p=13
|
||||
while($p>1)
|
||||
{
|
||||
eval delete from t2 where p1=$p and p2 = $p and p3=$p;
|
||||
dec $p;
|
||||
}
|
||||
--enable_query_log
|
||||
|
||||
select * from t2;
|
||||
select p1,p3 from t2;
|
||||
|
||||
replace into t2 values(1,1,1,0),(2,2,2,0),(3,3,3,0),(4,4,4,0),(5,4,4,0),(6,4,4,0),(7,4,6,0),(8,4,6,0),(9,4,6,0),(10,4,6,0),(11,4,6,0),(12,4,6,0), (13,4,6,0);
|
||||
|
||||
delete from t2 where p1>3 or p3 >=6;
|
||||
select * from t2;
|
||||
select p1,p3 from t2;
|
||||
delete from t2 where p1=1 and p3 =2;
|
||||
select * from t2;
|
||||
select p1,p3 from t2;
|
||||
delete from t2 where p1=1 and p2 =1 and p3=1;
|
||||
select * from t2;
|
||||
select p1,p3 from t2;
|
||||
|
||||
replace into t2 values(1,1,1,0),(2,2,2,0),(3,3,3,0),(4,4,4,0),(5,4,4,0),(6,4,4,0),(7,4,6,0),(8,4,6,0),(9,4,6,0),(10,4,6,0),(11,4,6,0),(12,4,6,0), (13,4,6,0);
|
||||
|
||||
delete from t2 where p1 in (1,2,3,6,7,8,12,13,0);
|
||||
select * from t2;
|
||||
|
||||
drop table t2;
|
||||
|
||||
|
||||
# mix common column and rowkey column
|
||||
create table t3 (p1 int, p2 int, p3 int, primary key(p1,p2));
|
||||
|
||||
insert into t3 values(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,4,4),(6,4,4),(7,4,6),(8,4,6),(9,4,6),(10,4,6),(11,4,6),(12,4,6), (13,4,6);
|
||||
delete from t3 where p1=1 and p2=1 and p3=1;
|
||||
select * from t3;
|
||||
select p1,p3 from t3;
|
||||
|
||||
replace into t3 values(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,4,4),(6,4,4),(7,4,6),(8,4,6),(9,4,6),(10,4,6),(11,4,6),(12,4,6), (13,4,6);
|
||||
delete from t3 where p1>3 or p3 >=6;
|
||||
select * from t3;
|
||||
select p1,p3 from t3;
|
||||
|
||||
delete from t3 where p1=1 and p3 =2;
|
||||
select * from t3;
|
||||
select p1,p3 from t3;
|
||||
|
||||
replace into t3 values(1,1,1),(2,2,2);
|
||||
delete from t3 where p1=1 and p2 =1 and p3=1;
|
||||
select * from t3;
|
||||
select p1,p3 from t3;
|
||||
|
||||
replace into t3 values(1,1,1),(2,2,2),(3,3,3),(4,4,4),(5,4,4),(6,4,4),(7,4,6),(8,4,6),(9,4,6),(10,4,6),(11,4,6),(12,4,6),(13,4,6);
|
||||
delete from t3 where p1 in (1,2,3,6,7,8,12,13,0);
|
||||
select * from t3;
|
||||
|
||||
drop table t3;
|
||||
|
||||
# where clause
|
||||
create table t4 (p1 varchar(100), p2 int, p3 datetime(6), p4 int, primary key(p1,p2,p3));
|
||||
|
||||
insert into t4 values('a', 41, '2012-10-23 17:14:00',0), ('b', 42, '2012-10-23 17:15:00',0), ('c', 43, '2012-10-23 17:16:00',0);
|
||||
delete from t4 where p3='2012-10-23 17:14:00';
|
||||
select * from t4;
|
||||
|
||||
replace into t4 values('a', 41, '2012-10-23 17:14:00',0), ('b', 42, '2012-10-23 17:15:00',0), ('c', 43, '2012-10-23 17:16:00',0);
|
||||
delete from t4 where p2='42';
|
||||
select * from t4;
|
||||
|
||||
replace into t4 values('a', 41, '2012-10-23 17:14:00',0), ('b', 42, '2012-10-23 17:15:00',0), ('c', 43, '2012-10-23 17:16:00',0);
|
||||
delete from t4 where p2<'401' and p1='c';
|
||||
select * from t4;
|
||||
|
||||
delete from t4 where p1='a' and p2=41 and p3='2012-10-23 17:14:00';
|
||||
select * from t4;
|
||||
|
||||
drop table t4;
|
||||
|
||||
create table t2(c1 int primary key, c2 int, c3 int);
|
||||
create table t3 (c1 int, c2 int, c3 int);
|
||||
|
||||
insert into t2 values (1, 1, 1);
|
||||
insert into t2 values (2, 2, 2);
|
||||
insert into t2 values (3, 2, 3);
|
||||
insert into t2 values (4, 6, 4);
|
||||
insert into t2 values (5, 4, 3);
|
||||
insert into t2 values (6, 4, 2);
|
||||
insert into t3 values(2, 2, 2);
|
||||
insert into t3 values(3, 3, 3);
|
||||
insert into t3 values(4, 4, 4);
|
||||
insert into t3 values(5, 5, 5);
|
||||
|
||||
delete t3 from t3, t2 where t3.c1 = t2.c2;
|
||||
delete t3 from t3, t2 where t3.c1 = t2.c1;
|
||||
--error 1235
|
||||
delete t3, t33 from t3 left join t3 as t33 on t3.c1 = t33.c1;
|
||||
select * from t3;
|
||||
select * from t2;
|
||||
|
||||
drop table t2;
|
||||
drop table t3;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists dns_inner_resource_record_info;
|
||||
--enable_warnings
|
||||
|
||||
CREATE TABLE `dns_inner_resource_record_info`(
|
||||
`id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
|
||||
`owner` varchar(256) NOT NULL COMMENT '资源',
|
||||
`cluster_name` varchar(20) NOT NULL COMMENT '所属集群 冗余字段',
|
||||
`zone_name` varchar(255) NOT NULL DEFAULT '' COMMENT 'ZONE NAME',
|
||||
`view_group_name` varchar(60) DEFAULT '' COMMENT 'VIEW GRP name',
|
||||
`domain_group_name` varchar(60) DEFAULT NULL COMMENT '域名组',
|
||||
`idc_id` varchar(20) DEFAULT NULL COMMENT 'IDC ID',
|
||||
`rr_type` varchar(10) NOT NULL COMMENT '资源类型',
|
||||
`ttl` varchar(20) NOT NULL DEFAULT '' COMMENT 'TTL',
|
||||
`rr_class` varchar(12) NOT NULL DEFAULT '' COMMENT 'RECODR 类型',
|
||||
`data` varchar(500) NOT NULL COMMENT '数据',
|
||||
`status` varchar(10) DEFAULT NULL COMMENT '状态',
|
||||
`gmt_create` datetime NOT NULL COMMENT '创建时间',
|
||||
`gmt_modified` datetime DEFAULT NULL COMMENT '修改时间',
|
||||
PRIMARY KEY (`id`),
|
||||
KEY `rrdata` (`data`(383)) BLOCK_SIZE 16384 GLOBAL,
|
||||
KEY `rrtype` (`rr_type`) BLOCK_SIZE 16384 GLOBAL,
|
||||
KEY `owner` (`owner`) BLOCK_SIZE 16384 GLOBAL,
|
||||
KEY `cluster` (`cluster_name`) BLOCK_SIZE 16384 GLOBAL,
|
||||
KEY `zonename` (`zone_name`) BLOCK_SIZE 16384 GLOBAL,
|
||||
KEY `viewgroupname` (`view_group_name`) BLOCK_SIZE 16384 GLOBAL,
|
||||
KEY `domain_group_name` (`domain_group_name`) BLOCK_SIZE 16384 GLOBAL,
|
||||
KEY `idc_id` (`idc_id`) BLOCK_SIZE 16384 GLOBAL
|
||||
) COMMENT = 'dns 内网集群资源记录表';
|
||||
delete from dns_inner_resource_record_info WHERE cluster_name = "1";
|
||||
set binlog_row_image='MINIMAL';
|
||||
delete from dns_inner_resource_record_info WHERE cluster_name = "1";
|
||||
drop table dns_inner_resource_record_info;
|
||||
|
||||
126
tools/deploy/mysql_test/test_suite/delete/t/deleteV2.test
Normal file
126
tools/deploy/mysql_test/test_suite/delete/t/deleteV2.test
Normal file
@ -0,0 +1,126 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
# owner: xiaoyi.xy
|
||||
# owner group: SQL3
|
||||
# description: 测试where比较条件的delete stmt, 单行删除
|
||||
# tags: delete,dml
|
||||
|
||||
--disable_abort_on_error
|
||||
|
||||
--echo can't determine a row
|
||||
|
||||
##case1
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(c1 int, c2 int, primary key(c1));
|
||||
|
||||
insert into t1 values(1,1),(2,2),(3,3);
|
||||
delete from t1 where c1 in(1);
|
||||
select * from t1;
|
||||
delete from t1 where c1 in(1,2);
|
||||
select * from t1;
|
||||
delete from t1 where c1>=3;
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1,1),(2,2),(3,3);
|
||||
delete from t1 where c1<=1;
|
||||
select * from t1;
|
||||
delete from t1 where 1>=c1;
|
||||
select * from t1;
|
||||
delete from t1 where 3<=c1;
|
||||
select * from t1;
|
||||
delete from t1 where 2<=c1;
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1,1),(2,2),(3,3);
|
||||
delete from t1 where c1>1 and c1<3;
|
||||
select * from t1;
|
||||
delete from t1 where c1=1 or c1=2;
|
||||
select * from t1;
|
||||
delete from t1 where c1<1 or c1<2;
|
||||
select * from t1;
|
||||
delete from t1 where c1=1 and c1=2;
|
||||
select * from t1;
|
||||
delete from t1 where c1>1 and c1=2;
|
||||
select * from t1;
|
||||
|
||||
##case2
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(c1 int, c2 int, primary key(c1));
|
||||
|
||||
insert into t1 values(1,1),(2,2),(3,3);
|
||||
delete from t1 where c2 in(1);
|
||||
select * from t1;
|
||||
delete from t1 where c2 in(1,2);
|
||||
select * from t1;
|
||||
delete from t1 where c2>=3;
|
||||
select * from t1;
|
||||
|
||||
insert into t1 values(1,1),(2,2),(3,3);
|
||||
delete from t1 where c2<=1;
|
||||
select * from t1;
|
||||
delete from t1 where 1>=c2;
|
||||
select * from t1;
|
||||
delete from t1 where 3<=c2;
|
||||
select * from t1;
|
||||
delete from t1 where c2>1 and c2<3;
|
||||
select * from t1;
|
||||
delete from t1 where c2=1 or c2=2;
|
||||
select * from t1;
|
||||
delete from t1 where c2<1 or c2<2;
|
||||
select * from t1;
|
||||
delete from t1 where c2=1 and c2=2;
|
||||
select * from t1;
|
||||
delete from t1 where c2>1 and c2=2;
|
||||
select * from t1;
|
||||
|
||||
##case3
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(c1 int, c2 int, primary key(c1));
|
||||
|
||||
insert into t1 values(1,1),(2,2),(3,3);
|
||||
delete from t1 where (c1,c2) in((1,1));
|
||||
select * from t1;
|
||||
delete from t1 where (c1,c2) in((1,1),(2,2));
|
||||
select * from t1;
|
||||
delete from t1 where (c2,c1) in((1,1));
|
||||
select * from t1;
|
||||
delete from t1 where (c2,c1) in((1,1),(2,2));
|
||||
select * from t1;
|
||||
delete from t1 where c1 > 1 and c2 >10 and c1=1;
|
||||
select * from t1;
|
||||
delete from t1 where c1 > 1 or c2 >10 and c1=1;
|
||||
select * from t1;
|
||||
|
||||
##case4
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(c1 int, c2 int, primary key(c1));
|
||||
insert into t1 values(1,1),(2,2),(3,3);
|
||||
delete from t1 where c2<=1;
|
||||
select * from t1;
|
||||
delete from t1 where 1>=c2;
|
||||
select * from t1;
|
||||
delete from t1 where 3<=c2;
|
||||
select * from t1;
|
||||
delete from t1 where c2>1 and c2<3;
|
||||
select * from t1;
|
||||
insert into t1 values(1,1),(2,2),(3,3);
|
||||
delete from t1 where c2=1 or c2=2;
|
||||
select * from t1;
|
||||
delete from t1 where c2<1 or c2<2;
|
||||
select * from t1;
|
||||
delete from t1 where c2=1 and c2=2;
|
||||
select * from t1;
|
||||
delete from t1 where c2>1 and c2=2;
|
||||
select * from t1;
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
264
tools/deploy/mysql_test/test_suite/delete/t/delete_range.test
Normal file
264
tools/deploy/mysql_test/test_suite/delete/t/delete_range.test
Normal file
@ -0,0 +1,264 @@
|
||||
--disable_query_log
|
||||
set @@session.explicit_defaults_for_timestamp=off;
|
||||
--enable_query_log
|
||||
# owner: xiaoyi.xy
|
||||
# owner group: SQL3
|
||||
# description: 本case是为了测试delete 一个range内的数据
|
||||
# tags: delete,dml
|
||||
|
||||
####TITLE: range delete
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
|
||||
|
||||
####CASE: single rowkey, using rowkey, >,>=,<,<=
|
||||
create table t1 (a int, b int, primary key (a));
|
||||
insert into t1(a,b) values(1,1),(2,1),(3,1),(4,1);
|
||||
delete from t1 where a=1;
|
||||
delete from t1 where a>0;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,1),(3,1),(4,1);
|
||||
delete from t1 where a<5;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,1),(3,1),(4,1);
|
||||
delete from t1 where a>1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(2,1),(3,1),(4,1);
|
||||
delete from t1 where a<4;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,1),(3,1);
|
||||
delete from t1 where a>=1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,1),(3,1),(4,1);
|
||||
delete from t1 where a<=5;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,1),(3,1),(4,1);
|
||||
delete from t1 where a>0 and a<2;
|
||||
delete from t1 where a>=2 and a<3;
|
||||
delete from t1 where a>=3 and a<=4;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,1),(3,1),(4,1);
|
||||
delete from t1 where a=1 or a=2 or a=3 or a=4;
|
||||
select * from t1;
|
||||
|
||||
####CASE: single rowkey, using non_rowkey, >, >=, <, <=
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where b>0;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where b<6;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where b>1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(2,2),(3,3),(4,4);
|
||||
delete from t1 where b<5;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where b>=1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where b<=7;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where b>0 and b<2;
|
||||
delete from t1 where b>=2 and b<3;
|
||||
delete from t1 where b>=3 and b<=4;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,3),(4,4);
|
||||
delete from t1 where b=1 or b=2 or b=3 or b=4;
|
||||
select * from t1;
|
||||
|
||||
####CASE: single rowkey: using rowkey + non_rowkey, >, >=, <,<=, or
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(a int, b int, c int, primary key(a));
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,1),(4,2);
|
||||
delete from t1 where a>0 and b>1;
|
||||
delete from t1 where a<5 and b<2;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,1),(4,2);
|
||||
delete from t1 where a>=0 and b<=1;
|
||||
delete from t1 where a<=5 and b>=2;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,1),(4,2);
|
||||
delete from t1 where a=0 or a=1 or a=2 or b=1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b) values(1,1),(2,2),(3,1),(4,2);
|
||||
delete from t1 where b=2 or a=1 or a=2;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c) values(1,1,NULL),(2,2,NULL),(3,3,NULL),(4,4,NULL);
|
||||
delete from t1 where a<=1 or b>=4;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c) values(1,1,NULL),(2,2,NULL),(3,3,NULL),(4,4,NULL);
|
||||
delete from t1 where a>1 or b<4;
|
||||
select * from t1;
|
||||
|
||||
####CASE: two rowkeys, using rowkey, >, >=, <, <=
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(a int, b int, c int, d int, primary key(a,b));
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b) > (0,0);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b) < (4,4);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b) >= (1,1);
|
||||
select * from t1;
|
||||
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b) <= (1,1);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b) in ((NULL,NULL),(0,0),(1,1),(2,2),(3,3),(4,4));
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b)=(1,1) or (a,b)=(2,2) or (a,b)=(3,3);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b) in ((1,1),(2,2),(3,3));
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b,c,d) >= (1,1,1,1);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b,c,d) <= (3,3,3,3);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,1,1),(3,3,1,1);
|
||||
delete from t1 where (a,b,c,d)=(1,1,1,1) or (a,b,c,d)=(2,2,1,1) or (a,b,c,d)=(3,3,3,3);
|
||||
select * from t1;
|
||||
|
||||
####CASE: two rowkeys, using one of rowkey, =, >, >=, <, <=
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(a int, b int, c int, d int, primary key(a,b));
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1);
|
||||
delete from t1 where a = 1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1);
|
||||
delete from t1 where a > 0;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1);
|
||||
delete from t1 where a >=1 ;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1);
|
||||
delete from t1 where a < 4;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1);
|
||||
delete from t1 where a <= 1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1);
|
||||
delete from t1 where a=1 or a=2 or a=3;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1);
|
||||
delete from t1 where (a=1 or a=2 or a=3) and (b=1 or b=2);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(1,2,1,1),(1,3,1,1);
|
||||
delete from t1 where a>=1 and b>=2;
|
||||
select * from t1;
|
||||
|
||||
####CASE:two rowkeys, using rowkey + non_rowkey, >, >=, <, <=, =
|
||||
--disable_warnings
|
||||
drop table if exists t1;
|
||||
--enable_warnings
|
||||
create table t1(a int, b int, c int, d int, primary key(a,b));
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where (a,b)>=(1,1) and c=1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where (a,b)>=(1,1) and c=3;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where (a=1 or a=2 or a=3) and c>=1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where (a=1 or a=2 or a=3) and c<1;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where (a=1 or a=2 or a=3) and (b=2 or b=3);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where (a=1 or a=2 or a=3) and (b=2 or b=3) and c=3;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where a>=0 and a<=3 and b>1 and b<3;
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where (c,d)>=(1,1);
|
||||
select * from t1;
|
||||
|
||||
replace into t1(a,b,c,d) values(1,1,1,1),(2,2,2,1),(3,3,3,1);
|
||||
delete from t1 where (b,a) > (1,1);
|
||||
select * from t1;
|
||||
|
||||
####CASE:multi rowkeys
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2, t3;
|
||||
--enable_warnings
|
||||
#int
|
||||
create table t1(a int, b int, c int, d int, primary key(a,b,c));
|
||||
insert into t1(a,b,c) values (1,1,1),(2,2,2),(3,3,3);
|
||||
delete from t1 where (a,b,c)>(0,0,0) and (a,b,c)<=(3,3,3);
|
||||
select * from t1;
|
||||
#varchar
|
||||
create table t2(a varchar(128), b varchar(128), c varchar(128), d varchar(128), primary key(a,b,c));
|
||||
insert into t2(a,b,c) values ('a','a','a'),('b','b','b'),('c','c','c');
|
||||
delete from t2 where (a,b,c)>=('a','a','b') and (a,b,c)<('b','b','c');
|
||||
select * from t2;
|
||||
#timestamp
|
||||
create table t3(a int, b varchar(128), c timestamp(6) default "2012-01-01 12:00:00", d int, primary key(a,b,c));
|
||||
insert into t3(a,b,c) values (1,'a','2014-02-17'),(2,'b','2014-02-17'),(3,'c','2014-02-18');
|
||||
delete from t3 where (a,b,c)>=(1,'a','2014-02-17 00:00:00') and (a,b,c)<=(2,'b','2014-02-18');
|
||||
select * from t3;
|
||||
|
||||
--disable_warnings
|
||||
drop table if exists t1, t2, t3;
|
||||
--enable_warnings
|
||||
Reference in New Issue
Block a user