0
自動順序列的值我有一個非常簡單的表:在SQL Management Studio中
+----------+-------------------------------------+----------------------------+
| StatusID | StatusName | Description |
+----------+-------------------------------------+----------------------------+
| 1 | Created |Something has been Created |
| 3 | Updated |Something has been Updated |
| 7 | Deleted |Something has been Deleted |
| 10 | Purged |Something has been Purged |
| 2 | Canceled |Something has been Cancelled|
+----------+-------------------------------------+----------------------------+
我插入不同StatusIDs,但他們沒有orderred上插入。我熟悉SQL中的ORDER BY語句,但是我想知道是否有一個自動ORDER選項是SQL管理工作室?所以,當我點擊我的表和選擇頂部X記錄時,我會自動獲得排序視圖?
創建視圖並在視圖中添加所需的順序。 –
@ShijuShaji除非還指定了TOP,OFFSET或FOR XML,否則在視圖,內聯函數,派生表,子查詢和公用表表達式中添加ORDER BY子句是無效的 –
大多數關係數據庫中的表具有聚集索引作爲主關鍵,那通常是記錄被檢索的順序,除非有一些碎片。讓我們在這裏明白,獲得保證訂單的唯一方法是明確添加一個order by子句 –