Pass index to temporary table from regular table?

前端 未结 2 1248
暖寄归人
暖寄归人 2021-01-06 00:45

I am creating a temp table with a query like this:

CREATE TEMPORARY TABLE temp_table
SELECT * FROM regular_table
WHERE 1

But regular_table

2条回答
  •  情书的邮戳
    2021-01-06 01:43

    A temporary table is exactly the same as any other table except that it will be dropped at the end of the session. The only way to have the same indexes (from within the database) is to create them on the table as you would any other table.

    Now there is a bit of a hack. You can copy the physical files on disk to a new name and have a clone of the table which includes indexes but I'm assuming you're doing this within an app so that might not be very practical.

提交回复
热议问题