SQLite 重新排序表?
可以通过查询对 SQLite 表列重新排序吗?
我更喜欢查询方法,但如果不可能,还有其他方法吗?
Can you reorder SQLite table columns via a query?
I would prefer a query method, but if that is not possible is there any other way?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以通过在查询中命名列的顺序来控制列的顺序。这两个查询返回相同的行,但列的顺序不同。
如果您希望基表中的列看起来已被永久更改,则可以使用视图。
如果您想让该更改对应用程序透明,您首先需要重命名表,然后创建视图,并为其指定表的旧名称。最后,您将跳过数据库管理系统所需的任何障碍,以使该视图可更新。在 SQLite 中,我认为这意味着编写代码来实现一些
INSTEAD OF
触发器< /a>.Yes, you control the order of columns by the order you name them in the query. Both these queries return the same rows, but the columns are in a different order.
If you want it to appear that the columns in the base table have been permanently changed, you can use a view.
If you wanted to make that change transparent to application programs, you'd first rename the table, then create the view, giving it the old name of the table. Finally, you'd jump through whatever hoops your dbms requires in order to make that view updatable. In SQLite, I think that means writing code to implement some
INSTEAD OF
triggers.