0

以下查询在 Sequel 中有效:

table_sizes = db_config["SELECT table_name,table_rows / 1000000 as table_rows, data_length / 1000000 as data_length, index_length / 1000000 as index_length,round(((data_length + index_length) / 1024 / 1024 / 1024),5) 'size'
FROM information_schema.TABLES 
WHERE table_schema = '#{db_name}' and table_name in ('table1','table2','table3'....'table20')"]

但是,当我做这样的事情时,这两个查询都不起作用:

arr = ['table1','table2','table3'...'table20']

table_sizes = db_config["SELECT table_name,table_rows / 1000000 as table_rows, data_length / 1000000 as data_length, index_length / 1000000 as index_length,round(((data_length + index_length) / 1024 / 1024 / 1024),5) 'size'
FROM information_schema.TABLES 
WHERE table_schema = '#{db_name}'"].filter(:table_name => arr)

或者:

table_sizes = db_config["SELECT table_name,table_rows / 1000000 as table_rows, data_length / 1000000 as data_length, index_length / 1000000 as index_length,round(((data_length + index_length) / 1024 / 1024 / 1024),5) 'size'
FROM information_schema.TABLES 
WHERE table_schema = '#{db_name}'"].where(:table_name => arr)

我应该怎么做?Sequel 不支持结果后过滤吗?

4

1 回答 1

1

Sequel 在获得查询结果后如何支持过滤?它的工作到那时就完成了。

Sequel 是一个 ORM,它减少了您编写 SQL 查询的需要,将生成的查询交给 DBM,检索结果并将它们传递给您的代码。

一旦你收到结果,续集就不在了。

基本上,您使用 Sequel 提供与数据库的连接,而忽略了它的所有其他优势和功能。

于 2013-05-27T14:52:50.090 回答