【求助】create ... as select 不支持临时表

各位专家好,麻烦问一下关于临时表的问题:

我采用手册两种方式建表,发现第一种方式不支持,第二种方式是支持的,如下:

CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name (table_definition_list) [table_option_list] [partition_option] [AS] select; CREATE [TEMPORARY] TABLE [IF NOT EXISTS] table_name LIKE table_name;

这里跟专家们确认一下,当前定义表结构的历史表在社区版是否不支持,只支持通过like方式copy临时表的方式?

1 个赞

不支持报错是什么?语法错误?还是其他什么错误

1 个赞
MySQL [test]> desc t1
    -> ;
+-------+---------+------+-----+---------+-------+
| Field | Type    | Null | Key | Default | Extra |
+-------+---------+------+-----+---------+-------+
| id    | int(11) | YES  |     | NULL    |       |
+-------+---------+------+-----+---------+-------+
1 row in set (0.002 sec)


MySQL [test]> create temporary table t4 as select;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'select' at line 1
MySQL [test]> create temporary table t4 as select * from t1;;
ERROR 1235 (0A000): View/Table's column refers to a temporary table not supported
ERROR: No query specified


MySQL [test]> create temporary table t4 as select id from t1;
ERROR 1235 (0A000): View/Table's column refers to a temporary table not supported
MySQL [test]> create temporary table t4(id int) as select id from t1;
ERROR 1235 (0A000): View/Table's column refers to a temporary table not supported
MySQL [test]> create temporary table t4(id int) as select  from t1;
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near 'from t1' at line 1
MySQL [test]> create temporary table t4 like t1;
Query OK, 0 rows affected (0.033 sec)


MySQL [test]>
1 个赞

目前暂时还不支持

2 个赞

看文档是支持临时表的呢

看报错,是对于第一种不支持的。

对是的,不知道有没有官方的回复

1 个赞

是否属于官方的回复嘿嘿

4.0 已经支持

1 个赞