mysql将查询结果生成临时表

MySQL中将查询的结果生成临时表,列类型与查询的列一致,百度搜索到的没啥用。

直接上SQL:

将结果生成临时表

create temporary table temp_tb_name as
(select id,name,update_time from  a_table where id<3)

手动创建临时表:

CREATE TEMPORARY TABLE temp_tb_bame(
    product_name VARCHAR(50) NOT NULL,
    total_sales DECIMAL(12,2) NOT NULL DEFAULT 0.00,
    avg_unit_price DECIMAL(7,2) NOT NULL DEFAULT 0.00,
    total_units_sold INT UNSIGNED NOT NULL DEFAULT 0
);

下面这种写法纯属误导:直接创建物理表了emm…
在这里插入图片描述

posted @ 2022-09-16 00:09  凌康  阅读(2721)  评论(0编辑  收藏  举报