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的優勢。 –