1 概述
1. 作用:临时表用来保存一些 '临时数据'
2. 注意:
(1) 临时表只在 '当前连接' 可见,当关闭连接时,Mysql 会 '自动删除表数据及表结构'
(2) 临时表 和 普通表 用法一样,用关键字 'temporary' 予以区别
2 实例
create temporary table temporary_test (
tid int,
tname varchar(50)
);
insert into temporary_test(tid, tname) values(1, 'a');
insert into temporary_test(tid, tname) values(2, 'b');
select * from temporary_test;
drop temporary table if exists temporary_test; -- 也可手动删除
session2:(新建一个查询窗口时,会提示:表不存在)
select * from temporary_test;