mysql

关键字:

temporary

  

代码:

select version();
-- 5.7.31-log

use mysql_study;

-- 临时表存在删除
drop table if exists temp_table;

-- 创建临时表
create temporary table temp_table
(
	id int not null,
	user_name varchar(20)
)engine = innodb default charset = utf8;

-- 这个是看不到临时表的
show tables;

-- 显示临时表结构
show columns from temp_table;

insert into temp_table(id, user_name) values(1, 'gyg');

select * from temp_table;

-- 如果你退出当前MySQL会话,再使用 SELECT命令来读取原先创建的临时表数据,那你会发现数据库中没有该表的存在,因为在你退出时该临时表已经被销毁了。
-- 关闭new query在打开就没了

  

原文地址:https://www.cnblogs.com/gygtech/p/13692040.html