0
下面的查询工作在续集:续集不支持结果后过滤吗?
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不支持过滤吗?
与其尝试将SQL查询包装在Sequel表数据集中,学习使用Sequel进行查询。你在做什么几乎没有改进写入原始SQL,并没有利用Sequel的优势。 –