# 全局临时表 (继续...)

__*GLOBAL TEMPORARY TABLE*__

```8
tidb> create ~!@global temporary@!~ table test.temp2 (id bigint);
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 52 near ""GLOBAL TEMPORARY and ~!@ON COMMIT DELETE ROWS@!~ must appear together 

tidb> create ~!@global temporary@!~ table test.temp2 (id bigint) on commit delete rows;
Query OK, 0 rows affected (0.57 sec)

tidb> set @@autocommit = 'OFF';

tidb> insert into test.temp2 values (10);

tidb> select * from test.temp2;
+------+
| id   |
+------+
|   10 |
+------+
1 row in set (0.00 sec)

tidb> commit;

tidb> select * from test.temp2;
Empty set (0.00 sec)
```
-------------------------------------------------

创建全局临时表时,必须使用 ON COMMIT DELETE ROWS。

当事务结束时,全局临时表中的所有行都将丢失。
