根据现有数据对SQLServer中的表进行永久排序 [英] Permanently sorting a table in SQLServer based on pre-existing data

查看:313
本文介绍了根据现有数据对SQLServer中的表进行永久排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经基于现有数据在SQL Server中创建了一个表:

I have made a table in SQL Server based on pre-existing data:

SELECT pre_existing_data
INTO new_table
FROM existing_table

创建表后,我试图使输出按特定字段进行永久排序.我认为这很简单,就像在构成表的代码块的末尾添加ORDER BY子句一样,但是数据仍然无法正确排序.

I am trying to get the output to permanently sort by a particular field once the table is created. I thought this would be as simple as adding an ORDER BY clause at the end of the chunk of code that makes the table, but the data still won't sort properly.

推荐答案

无法对SQL中的表进行永久排序.

There is no way to permanently sort a table in SQL.

您可以在表上创建索引,使用索引的查询(在ORDER BY子句中)将更快地返回,但是数据在磁盘上存储的顺序是不可控制的.

You can create an index on the table and queries which use the index (in an ORDER BY clause) will be returned quicker, but the order the data is stored on the disk is not controllable.

这篇关于根据现有数据对SQLServer中的表进行永久排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆