home *** CD-ROM | disk | FTP | other *** search
/ MacWorld 2003 May (DVD) / Macworld Resource DVD May 2003.toast / Data / Software / Bonus / Database / mysql-max-3.23.55.sit / mysql-max-3.23.55-apple-darwi.1 / mysql-test / t / heap.test < prev    next >
Encoding:
Text File  |  2003-01-21  |  3.3 KB  |  103 lines  |  [TEXT/ttxt]

  1. #
  2. # Test of heap tables.
  3. #
  4.  
  5. drop table if exists t1;
  6. create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps" avg_row_length=100 min_rows=1 max_rows=100;
  7. insert into t1 values(1,1),(2,2),(3,3),(4,4);
  8. delete from t1 where a=1 or a=0;
  9. #show table status like "t1";
  10. show keys from t1;
  11. select * from t1;
  12. select * from t1 where a=4;
  13. update t1 set b=5 where a=4;
  14. update t1 set b=b+1 where a>=3;
  15. replace t1 values (3,3);
  16. select * from t1;
  17. alter table t1 add c int not null, add key (c,a);
  18. drop table t1;
  19.  
  20. create table t1 (a int not null,b int not null, primary key (a)) type=heap comment="testing heaps";
  21. insert into t1 values(1,1),(2,2),(3,3),(4,4);
  22. alter table t1 modify a int not null auto_increment, type=myisam, comment="new myisam table";
  23. #show table status like "t1";
  24. select * from t1;
  25. drop table t1;
  26.  
  27. create table t1 (a int not null) type=heap;
  28. insert into t1 values (869751),(736494),(226312),(802616);
  29. select * from t1 where a > 736494;
  30. alter table t1 add unique uniq_id(a);
  31. select * from t1 where a > 736494;
  32. select * from t1 where a = 736494;
  33. select * from t1 where a=869751 or a=736494;
  34. select * from t1 where a in (869751,736494,226312,802616);
  35. alter table t1 type=myisam;
  36. explain select * from t1 where a in (869751,736494,226312,802616);
  37. drop table t1;
  38.  
  39. create table t1 (x int not null, y int not null, key x(x), unique y(y))
  40. type=heap;
  41. insert into t1 values (1,1),(2,2),(1,3),(2,4),(2,5),(2,6);
  42. select * from t1 where x=1;
  43. select * from t1,t1 as t2 where t1.x=t2.y;
  44. explain select * from t1,t1 as t2 where t1.x=t2.y;
  45. drop table t1;
  46.  
  47. create table t1 (a int) type=heap;
  48. insert into t1 values(1);
  49. select max(a) from t1;
  50. drop table t1;
  51.  
  52. CREATE TABLE t1 ( a int not null default 0, b int not null default 0,  key(a),  key(b)  ) TYPE=HEAP;
  53. insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
  54. select * from t1 where a=1; 
  55. insert into t1 values(1,1),(1,2),(2,3),(1,3),(1,4),(1,5),(1,6);
  56. select * from t1 where a=1;
  57. drop table t1;
  58.  
  59. create table t1 (id int unsigned not null, primary key (id)) type=HEAP;
  60. insert into t1 values(1);
  61. select max(id) from t1; 
  62. insert into t1 values(2);
  63. select max(id) from t1; 
  64. replace into t1 values(1);
  65. drop table t1;
  66.  
  67. create table t1 (n int) type=heap;
  68. drop table t1;
  69.  
  70. create table t1 (n int) type=heap;
  71. drop table if exists t1;
  72.  
  73. # Test of non unique index
  74.  
  75. CREATE table t1(f1 int not null,f2 char(20) not 
  76. null,index(f2)) type=heap;
  77. INSERT into t1 set f1=12,f2="bill";
  78. INSERT into t1 set f1=13,f2="bill";
  79. INSERT into t1 set f1=14,f2="bill";
  80. INSERT into t1 set f1=15,f2="bill";
  81. INSERT into t1 set f1=16,f2="ted";
  82. INSERT into t1 set f1=12,f2="ted";
  83. INSERT into t1 set f1=12,f2="ted";
  84. INSERT into t1 set f1=12,f2="ted";
  85. INSERT into t1 set f1=12,f2="ted";
  86. delete from t1 where f2="bill";
  87. select * from t1;
  88. drop table t1;
  89.  
  90. #
  91. # Test when using part key searches
  92. #
  93.  
  94. create table t1 (btn char(10) not null, key(btn)) type=heap;
  95. insert into t1 values ("hello"),("hello"),("hello"),("hello"),("hello"),("a"),("b"),("c"),("d"),("e"),("f"),("g"),("h"),("i");
  96. explain select * from t1 where btn like "q%";
  97. select * from t1 where btn like "q%";
  98. alter table t1 add column new_col char(1) not null, add key (btn,new_col), drop key btn;
  99. update t1 set new_col=btn;
  100. explain select * from t1 where btn="a";
  101. explain select * from t1 where btn="a" and new_col="a";
  102. drop table t1;
  103.