由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Database版 - 急问一个奇怪的sql server数据库问题
相关主题
问一个queryurgent help! insert value into table
[转载] 求教数据库的query optimization 工作的面试sql面试题1
question: copy first N rows from table B to table A (DB2)MS T-SQL 问题
SQL中怎样用定制列排序?help! 怎么insert一个多行的string
query 求助[转载] JDBC 处理日期的问题(日期插入数据库)
how to improve the performance of Oracle Insert operation?JDBC<======================>Oracle8i
Oracle prefetch的问题JDBC: How to get Identity after insert
Help on Sql server huge table performancesome JDBC Oracle related questions
相关话题的讨论汇总
话题: order话题: select话题: sql话题: attr话题: server
进入Database版参与讨论
1 (共1页)
q****g
发帖数: 12
1
我用jdbc操作 sql server下的 database时,
遇到一个奇怪的现象:比如说一个简单的语句:
SELECT id, attr
INTO tempTB
FROM TB
WHERE (...)
ORDER BY attr
返回的tempTB 有的时候根本不是按照attr排序的,
确切地说,只是部分排序。比如说如果数据范围[1,1000],
输出的结果可能是 992 993,...1000, 876,877,878,。。
我多run几次,有时候又能输出正确排序后的结果。
有人遇到过这种情况么?到底怎么回事啊?
难道是sql server安装有问题?
但是我的机器刚刚重装过,以前用这个sql server的安装文件
也装过,从来没有碰到过这种问题。
k***e
发帖数: 12
2
When select from tempTB, you need to use order by attr to gurantee the
returned result is ordered.
q****g
发帖数: 12
3
Thanks!I've also found the reason from the website,
order by在select into 或者insert里面都是没用/unpredictable的:
Tables do not have an order. In other words, tables by definition are
logically an unordered set of rows. Using ORDER BY in a INSERT...SELECT or
SELECT...INTO does not mean that the data in the table is 'ordered'. The
order of rows which you see when you do a SELECT without an ORDER BY clause
is a undefined/arbitrary order chosen by the optimizer based on the physical
characteristics, indexes,

【在 k***e 的大作中提到】
: When select from tempTB, you need to use order by attr to gurantee the
: returned result is ordered.

1 (共1页)
进入Database版参与讨论
相关主题
some JDBC Oracle related questionsquery 求助
请教一个sql server的问题how to improve the performance of Oracle Insert operation?
a question for JDBCOracle prefetch的问题
一个JDBC的问题,希望大家指教!Help on Sql server huge table performance
问一个queryurgent help! insert value into table
[转载] 求教数据库的query optimization 工作的面试sql面试题1
question: copy first N rows from table B to table A (DB2)MS T-SQL 问题
SQL中怎样用定制列排序?help! 怎么insert一个多行的string
相关话题的讨论汇总
话题: order话题: select话题: sql话题: attr话题: server