temp_table.test
Upload User: tsgydb
Upload Date: 2007-04-14
Package Size: 10674k
Code Size: 2k
Category:

MySQL

Development Platform:

Visual C++

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