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

  1. #
  2. # Test of temporary tables
  3. #
  4.  
  5. drop table if exists t1,t2;
  6. CREATE TABLE t1 (c int not null, d char (10) not null);
  7. insert into t1 values(1,""),(2,"a"),(3,"b");
  8. CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
  9. insert into t1 values(4,"e"),(5,"f"),(6,"g");
  10. alter table t1 rename t2;
  11. select * from t1;
  12. select * from t2;
  13. CREATE TABLE t2 (x int not null, y int not null);
  14. alter table t2 rename t1;
  15. select * from t1;
  16. create TEMPORARY TABLE t2 type=heap select * from t1;
  17. create TEMPORARY TABLE IF NOT EXISTS t2 (a int) type=heap;
  18.  
  19. # This should give errors
  20. !$1050 CREATE TEMPORARY TABLE t1 (a int not null, b char (10) not null);
  21. !$1050 ALTER TABLE t1 RENAME t2;
  22.  
  23. select * from t2;
  24. alter table t2 add primary key (a,b);
  25. drop table t1,t2;
  26. select * from t1;
  27. drop table t2;
  28. create temporary table t1 select *,2 as "e" from t1;
  29. select * from t1;
  30. drop table t1;
  31. drop table t1;
  32.  
  33. #
  34. # Test CONCAT_WS with temporary tables
  35. #
  36.  
  37. drop table if exists t1;
  38. CREATE TABLE t1 (pkCrash INTEGER PRIMARY KEY,strCrash VARCHAR(255));
  39. INSERT INTO t1 ( pkCrash, strCrash ) VALUES ( 1, '1');
  40. SELECT CONCAT_WS(pkCrash, strCrash) FROM t1;
  41. drop table t1;
  42. create temporary table t1 select 1 as 'x';
  43. drop table t1;
  44. CREATE TABLE t1 (x INT);
  45. INSERT INTO t1 VALUES (1), (2), (3);
  46. CREATE TEMPORARY TABLE tmp SELECT *, NULL FROM t1;
  47. drop table t1;
  48.  
  49. #
  50. # Problem with ELT
  51. #
  52. create temporary table t1 (id int(10) not null unique);
  53. create temporary table t2 (id int(10) not null primary key, 
  54. val int(10) not null);
  55.  
  56. # put in some initial values
  57. insert into t1 values (1),(2),(4);
  58. insert into t2 values (1,1),(2,1),(3,1),(4,2);
  59.  
  60. # do a query using ELT, a join and an ORDER BY.
  61. select one.id, two.val, elt(two.val,'one','two') from t1 one, t2 two where two.id=one.id order by one.id;
  62. drop table t1,t2;
  63. create temporary table t1 (a int not null);
  64. insert into t1 values (1),(1);
  65. -- error 1062
  66. alter table t1 add primary key (a);
  67. drop table t1;
  68.