ndb_subquery.result
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:2k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. drop table if exists t1;
  2. drop table if exists t2;
  3. create table t1 (p int not null primary key, u int not null, o int not null,
  4. unique (u), key(o)) engine=ndb;
  5. create table t2 (p int not null primary key, u int not null, o int not null,
  6. unique (u), key(o)) engine=ndb;
  7. insert into t1 values (1,1,1),(2,2,2),(3,3,3);
  8. insert into t2 values (1,1,1),(2,2,2),(3,3,3), (4,4,4), (5,5,5);
  9. explain select * from t2 where p NOT IN (select p from t1);
  10. id select_type table type possible_keys key key_len ref rows Extra
  11. 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
  12. 2 DEPENDENT SUBQUERY t1 unique_subquery PRIMARY PRIMARY 4 func 1 Using index
  13. select * from t2 where p NOT IN (select p from t1) order by p;
  14. p u o
  15. 4 4 4
  16. 5 5 5
  17. explain select * from t2 where p NOT IN (select u from t1);
  18. id select_type table type possible_keys key key_len ref rows Extra
  19. 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
  20. 2 DEPENDENT SUBQUERY t1 unique_subquery u u 4 func 1 Using index
  21. select * from t2 where p NOT IN (select u from t1) order by p;
  22. p u o
  23. 4 4 4
  24. 5 5 5
  25. explain select * from t2 where p NOT IN (select o from t1);
  26. id select_type table type possible_keys key key_len ref rows Extra
  27. 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
  28. 2 DEPENDENT SUBQUERY t1 index_subquery o o 4 func 1 Using index
  29. select * from t2 where p NOT IN (select o from t1) order by p;
  30. p u o
  31. 4 4 4
  32. 5 5 5
  33. explain select * from t2 where p NOT IN (select p+0 from t1);
  34. id select_type table type possible_keys key key_len ref rows Extra
  35. 1 PRIMARY t2 ALL NULL NULL NULL NULL 5 Using where
  36. 2 DEPENDENT SUBQUERY t1 ALL NULL NULL NULL NULL 3 Using where
  37. select * from t2 where p NOT IN (select p+0 from t1) order by p;
  38. p u o
  39. 4 4 4
  40. 5 5 5
  41. drop table t1;
  42. drop table t2;