如何更改列的顺序 [英] how to change the order of columns
本文介绍了如何更改列的顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在Rails控制台中通过'MODEL.all'命令获得了数据
I got the data by 'MODEL.all' command in rails console
我想在运行<$时将列'cgi_name'放在第三位c $ c> MODEL.all 在Rails控制台中
I want to put the column 'cgi_name' in the 3rd position when I run MODEL.all
in the rails console
我使用 postgres
对于我的数据库
如何获取它?
推荐答案
简单的答案是您不能
使用选择时,无法重新排序要显示的列名Model.all
。
否则,您可以通过按所需顺序选择每一列来重新排序。
Otherwise, you can re-order this by selecting each column in the order you want.
Model.select("column1, column2, cgi_name, column4 etc..")
希望有帮助:)
这篇关于如何更改列的顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文