MySQL临时表问题
我正在尝试使用临时表来加速我的 MySQL 4.1.22 标准数据库,看似简单的操作却给我带来了各种问题。 我的代码如下......
CREATE TEMPORARY TABLE nonDerivativeTransaction_temp (
accession_number varchar(30),
transactionDateValue date)
) TYPE=HEAP;
INSERT INTO nonDerivativeTransaction_temp
VALUES( SELECT accession_number, transactionDateValue
FROM nonDerivativeTransaction
WHERE transactionDateValue = "2010-06-15");
SELECT *
FROM nonDerivativeTransaction_temp;
原始表(nonDerivativeTransaction)有两个字段,accession_number(varchar(30))和transactionDateValue(日期)。
显然我对前两个陈述有疑问,但我似乎无法确定它是什么。任何帮助将不胜感激。
I'm trying to use temp tables to speed up my MySQL 4.1.22-standard database and what seems like a simple operation is causing me all kinds of issues.
My code is below....
CREATE TEMPORARY TABLE nonDerivativeTransaction_temp (
accession_number varchar(30),
transactionDateValue date)
) TYPE=HEAP;
INSERT INTO nonDerivativeTransaction_temp
VALUES( SELECT accession_number, transactionDateValue
FROM nonDerivativeTransaction
WHERE transactionDateValue = "2010-06-15");
SELECT *
FROM nonDerivativeTransaction_temp;
The original table (nonDerivativeTransaction) has two fields, accession_number (varchar(30)) and transactionDateValue (date).
Apparently I am getting an issue with the first two statements but I can't seem to nail down what it is. Any help would be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将
INSERT INTO ... VALUES ( SELECT
) 中的VALUES(
) 删除,它是 VALUES() 或 SELECT,而不是两者。通常,您的这种设置会减慢速度然后加快它们的速度,除非您在会话期间大量查询临时表,并且查询缓存已关闭和/或不可行。
Drop the
VALUES(
inINSERT INTO ... VALUES ( SELECT
, it's either VALUES() or SELECT, not both.And normally this setup of yours would slow down things rather then speed them up unless you're querying the temporary table a LOT during the session, and query-caching is off and/or not feasible.
快速浏览一下让我想知道不匹配的括号是否可能是您问题的一部分......
A quick look makes me wonder if the mismatched parens might be part of your problem...