简体   繁体   English

Rails-不同的HTTP请求之间是否存在mysql临时表

[英]Rails - Does mysql temporary table available between different http request

I have written a code to create temporary table on every http request. 我已经编写了一个代码,可以在每个http请求上创建临时表。 For the very first request table is created successfully however on the second request it gives me error as Table 'xxx' already exists . 对于第一个请求表,创建成功,但是在第二个请求上,由于Table 'xxx' already exists它给了我错误。 when i restarted my local machine server(thin web server) and hit the http request then again temporary table is created without error. 当我重新启动本地计算机服务器(瘦Web服务器)并点击http请求时,再次创建了临时表而没有错误。

Does this mean that temporary tables are shared between different http request and are destroyed automatically when machine or server is restarted?? 这是否意味着临时表在不同的HTTP请求之间共享,并且在计算机或服务器重新启动时会自动销毁?

Thanks, 谢谢,

As far as I know temporary table exists until connection to the database is closed. 据我所知,临时表存在直到关闭与数据库的连接。 In Rais you have a pool of connections to the database and different requests can use different connections. 在Rais中,您有一个到数据库的连接池,不同的请求可以使用不同的连接。

So if you create temporary table in the first http request, second request can use the same connection and you can receive a SQL error when is trying to create it again, but in second request use another connection temporary table will not exist yet. 因此,如果您在第一个http请求中创建临时表,则第二个请求可以使用相同的连接,并且在尝试再次创建它时会收到SQL错误,但是在第二个请求中使用另一个连接的临时表将不存在。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM