它爲我
[email protected]:~$ mysql -uroot -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 334
Server version: 5.5.29-0ubuntu0.12.04.1 (Ubuntu)
Copyright (c) 2000, 2012, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> use world_innodb;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A
Database changed
mysql> DROP TEMPORARY TABLE IF EXISTS rep1;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> DROP TEMPORARY TABLE IF EXISTS rep2;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql> DROP TEMPORARY TABLE IF EXISTS rep3;
Query OK, 0 rows affected, 1 warning (0.00 sec)
mysql>
mysql> CREATE TEMPORARY TABLE `rep1`(SELECT * FROM world_innodb.City);
Query OK, 4079 rows affected (1.70 sec)
Records: 4079 Duplicates: 0 Warnings: 0
mysql> CREATE TEMPORARY TABLE `rep2`(SELECT * FROM world_innodb.City);
Query OK, 4079 rows affected (1.29 sec)
Records: 4079 Duplicates: 0 Warnings: 0
mysql>
mysql> CREATE TEMPORARY TABLE `rep3` SELECT * FROM `rep1` UNION ALL SELECT * FROM `rep2`;
Query OK, 8158 rows affected (2.50 sec)
Records: 8158 Duplicates: 0 Warnings: 0
mysql> SELECT * FROM `rep3` LIMIT 10;
+----+----------------+-------------+---------------+------------+
| ID | Name | CountryCode | District | Population |
+----+----------------+-------------+---------------+------------+
| 1 | Kabul | AFG | Kabol | 1780000 |
| 2 | Qandahar | AFG | Qandahar | 237500 |
| 3 | Herat | AFG | Herat | 186800 |
| 4 | Mazar-e-Sharif | AFG | Balkh | 127800 |
| 5 | Amsterdam | NLD | Noord-Holland | 731200 |
| 6 | Rotterdam | NLD | Zuid-Holland | 593321 |
| 7 | Haag | NLD | Zuid-Holland | 440900 |
| 8 | Utrecht | NLD | Utrecht | 234323 |
| 9 | Eindhoven | NLD | Noord-Brabant | 201843 |
| 10 | Tilburg | NLD | Noord-Brabant | 193238 |
+----+----------------+-------------+---------------+------------+
10 rows in set (0.00 sec)
在MySQL
TEMPORARY TABLES
工作是基於會話的,你不能從另一個會話訪問它們。您是否正在訪問其他會話的表格?您需要在同一個會話中訪問它們。
您正在使用的工具 – YasirPoongadan
沒有工具,我只是在Linux機器上的'MySQL提示符'上執行。 –
更新了我的答案! –