CREATE TABLE as SELECT - using MEMORY ENGINE (in RAM memory)

后端 未结 2 1994
广开言路
广开言路 2020-12-25 13:35

I was reading about tables using MEMORY ENGINE (tables stored in ram).

  • Is it possible to use CREATE TABLE AS SELECT syntax, but have the create

2条回答
  •  北海茫月
    2020-12-25 14:12

    you can also create a temporary table this way:

    CREATE TEMPORARY TABLE IF NOT EXISTS tmp ENGINE=MEMORY AS (
    SELECT 'abc' As tomcat, 'def' As apache);
    

    Or this way:

    CREATE TEMPORARY TABLE IF NOT EXISTS tmp ENGINE=MEMORY AS (
    SELECT tomcat, apache From servers);
    

    Be advised, the first option will create the two columns as varchar(3), meanwhile the second option will import any column information from the original table, even their comments.

提交回复
热议问题