正确的语法如果不存在'

时间:2014-04-23 18:33:01

标签: mysql

创建临时表的正确原因是什么?

CREATE TEMPORARY TABLE indexed_temp IF NOT EXIST
  temp_table ( INDEX(locationcode) ) 
AS (
  SELECT customerid, locationcode
  FROM cardbatch
)
CREATE TEMPORARY TABLE indexed_temp2 IF NOT EXIST
  temp_table ( INDEX(cia_locationid) ) 
AS (
  SELECT cia_customerid, cia_locationid
  FROM cardinventoryalerts
)



ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'IF NOT EXIST   temp_table ( INDEX(locationcode) )  AS (   SELECT customerid, loc' at line 1

1 个答案:

答案 0 :(得分:1)

@brad,注意你的代码。

您正在撰写IN NOT EXIST而不是IF NOT EXISTS

CREATE TEMPORARY TABLE indexed_temp IF NOT EXISTS (...)

正如@tadman所说,documentation非常明确且乐于助人:)