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 / auto_increment.test < prev    next >
Encoding:
Text File  |  2003-01-21  |  2.3 KB  |  78 lines  |  [TEXT/ttxt]

  1. #
  2. # Test of auto_increment;  The test for BDB tables is in bdb.test
  3. #
  4.  
  5. create table t1 (a int not null auto_increment,b int, primary key (a)) type=myisam auto_increment=3;
  6. insert into t1 values (1,1),(NULL,3),(NULL,4);
  7. delete from t1 where a=4;
  8. insert into t1 values (NULL,5),(NULL,6);
  9. select * from t1;
  10. delete from t1 where a=6;
  11. #show table status like "t1";
  12. replace t1 values (3,1);
  13. ALTER TABLE t1 add c int;
  14. replace t1 values (3,3,3);
  15. insert into t1 values (NULL,7,7);
  16. update t1 set a=8,b=b+1,c=c+1 where a=7;
  17. insert into t1 values (NULL,9,9);
  18. select * from t1;
  19. drop table t1;
  20.  
  21. create table t1 (a int not null auto_increment,b int, primary key (a)) type=isam;
  22. insert into t1 values (1,1),(NULL,2),(3,3),(NULL,4);
  23. delete from t1 where a=4 or a=2;
  24. insert into t1 values (NULL,4),(NULL,5),(6,6);
  25. select * from t1;
  26. delete from t1 where a=6;
  27. #show table status like "t1";
  28. replace t1 values (3,1);
  29. replace t1 values (3,3);
  30. ALTER TABLE t1 add c int;
  31. insert into t1 values (NULL,6,6);
  32. select * from t1;
  33. drop table t1;
  34.  
  35. create table t1 (
  36.   skey tinyint unsigned NOT NULL auto_increment PRIMARY KEY,
  37.   sval char(20)
  38. );
  39. insert into t1 values (NULL, "hello");
  40. insert into t1 values (NULL, "hey");
  41. select * from t1;
  42. select _rowid,t1._rowid,skey,sval from t1;
  43. drop table t1;
  44.  
  45. #
  46. # Test auto_increment on sub key
  47. #
  48. create table t1 (a char(10) not null, b int not null auto_increment, primary key(a,b));
  49. insert into t1 values ("a",1),("b",2),("a",2),("c",1);
  50. insert into t1 values ("a",NULL),("b",NULL),("c",NULL),("e",NULL);
  51. insert into t1 (a) values ("a"),("b"),("c"),("d");
  52. insert into t1 (a) values ('k'),('d');
  53. insert into t1 (a) values ("a");
  54. insert into t1 values ("d",last_insert_id());
  55. select * from t1;
  56. drop table t1;
  57.  
  58. create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ordid), index(ord,ordid)); 
  59. insert into t1 (ordid,ord) values (NULL,'sdj'),(NULL,'sdj');
  60. select * from t1;
  61. drop table t1;
  62.  
  63. create table t1 (ordid int(8) not null auto_increment, ord  varchar(50) not null, primary key (ord,ordid));
  64. insert into t1 values (NULL,'sdj'),(NULL,'sdj'),(NULL,"abc"),(NULL,'abc'),(NULL,'zzz'),(NULL,'sdj'),(NULL,'abc');
  65. select * from t1;
  66. drop table t1;
  67.  
  68. #
  69. # Test of auto_increment columns when they are set to 0
  70. #
  71.  
  72. create table t1 (a int not null primary key auto_increment);
  73. insert into t1 values (0);
  74. update t1 set a=0;
  75. select * from t1;
  76. check table t1;
  77. drop table t1;
  78.