久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

當種子以最大負值開始時,SQL 表中的最大行數其

Max rows in SQL table where PK is INT 32 when seed starts at max negative value?(當種子以最大負值開始時,SQL 表中的最大行數其中 PK 為 INT 32?)
本文介紹了當種子以最大負值開始時,SQL 表中的最大行數其中 PK 為 INT 32?的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

主鍵標識為 INT 32 類型的 SQL 服務器表中的最大行數:

Is the maximum number of rows in an SQL server table where the Primary Key Identity is INT 32 type:

4,294,967,294

4,294,967,294

即 2,147,483,647 個正數加上 2,147,483,647 個負數

i.e 2,147,483,647 positive numbers add 2,147,483,647 negative numbers

我問的原因是一個系統注定要使用所有 2,147,483,647 個數字.

The reason I ask is a system was destined to use all 2,147,483,647 numbers.

在 -2,147,483,647 個月前成功將種子重置為負數.

Reset the seed to negative -2,147,483,647 months ago successfully.

還實現了一個代理任務來刪除未使用的正數.

Also implemented an Agent task to remove unused positive numbers.

每天對 PK ID 的表計數檢查報告表中的行數驚人地接近 2,147,483,647,但迄今為止尚未違反.

Table count check of PK ID each day reports the number of rows in the table is tantalisingly close to 2,147,483,647 but has not breached to date.

周六 28/2,125,167,844

Sat 28 / 2,125,167,844

星期五 27/2,128,445,105

Fri 27 / 2,128,445,105

星期四 26/2,128,704,866

Thur 26 / 2,128,704,866

星期三 25/2,128,935,436

Wed 25 / 2,128,935,436

周六 21/2,141,016,422

Sat 21 / 2,141,016,422

星期四 19/2,143,413,531

Thur 19 / 2,143,413,531

理論上,如果使用的所有正負標識都正確,那么這個行數應該達到 4,294,967,294 嗎?

In theory this row count should reach 4,294,967,294 if all positive and negative identities where in use correct ?

奇怪的是,此計數從未大于最大正值.下面的查詢是一個簡單的行數,+/- 標識應該無關緊要.

Find it odd that this count has never been greater than the max positive value. The query below is a simple row count, +/- identities should not matter.

選擇 COUNT (id) from table with (NOLOCK)

select COUNT (id) from table with (NOLOCK)

謝謝

推薦答案

是的,您可以再次一直到標識 0,并且您可以在表中保存 4,294,967,294 條記錄.但是你說你正在刪除未使用的正數",如果這個過程總是先刪除最舊的記錄,那么它應該會帶來很多麻煩.如果您要刪除隨機數據,請不要指望這些數字會被身份自動使用.插入標識列時,SQL Server 會記住最后插入的標識并將其加 1,然后插入,如果數字存在,如果該列上有唯一鍵,則會給出鍵沖突錯誤.

Yes you can go all the way up to identity 0 again and you could go up to holding 4,294,967,294 records in your table. However you say you're "removing unused positive numbers" if this process always deletes the oldest records first then it should give much troubles. If you're deleting random data don't expect those numbers to be automatically be used by identity. When inserting into an identity column SQL Server remembers the last inserted identity and increments it by 1 and then does the insert, if the number exists, it will give a key violation error if there is a unique key on that column.

PS:有更快的方法來計算表中的所有行:

PS: There are faster ways to count all rows in a table:

SELECT SUM (row_count)
FROM sys.dm_db_partition_stats
WHERE object_id=OBJECT_ID('Transactions')   
AND (index_id=0 or index_id=1);

PS2:確保將計數結果放入 bigint ;)

PS2: Makes sure to put the result of an count in a bigint ;)

這篇關于當種子以最大負值開始時,SQL 表中的最大行數其中 PK 為 INT 32?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Converting Every Child Tags in to a Single Column with multiple Delimiters -SQL Server (3)(將每個子標記轉換為具有多個分隔符的單列-SQL Server (3))
How can I create a view from more than one table?(如何從多個表創建視圖?)
Create calculated value based on calculated value inside previous row(根據前一行內的計算值創建計算值)
How do I stack the first two columns of a table into a single column, but also pair third column with the first column only?(如何將表格的前兩列堆疊成一列,但也僅將第三列與第一列配對?) - IT屋-程序員軟件開發技
Recursive t-sql query(遞歸 t-sql 查詢)
Convert Month Name to Date / Month Number (Combinations of Questions amp; Answers)(將月份名稱轉換為日期/月份編號(問題和答案的組合))
主站蜘蛛池模板: 久久日韩粉嫩一区二区三区 | 午夜欧美一区二区三区在线播放 | 亚洲高清av在线 | 一区二区三区四区在线 | 九九综合| 狠狠撸在线视频 | 国产成人av免费看 | 99精品在线免费观看 | 国产精品久久久亚洲 | 天堂色区| 成人一级黄色毛片 | 搞黄视频免费看 | 一区二区三区高清 | 日韩精品在线免费 | www网站在线观看 | 亚洲天堂精品久久 | 日日夜夜免费精品 | 欧美日韩国产一区二区三区 | 日韩网站免费观看 | 久久精品视频网站 | 伊人伊成久久人综合网站 | 久久久久久久久久久久一区二区 | 精品国产一区二区三区av片 | 在线观看中文字幕视频 | 欧美精品欧美精品系列 | 久久99精品久久久久久噜噜 | 久久久91精品国产一区二区精品 | 四虎国产 | 中文字幕免费视频 | 成人亚洲精品久久久久软件 | 中文字幕视频在线观看 | 国产精彩视频 | 久久精品伊人 | 日韩视频在线免费观看 | 日韩精品视频在线 | 久久三区| 国产69精品久久久久777 | 9999国产精品欧美久久久久久 | 免费在线成人 | 伦理二区 | 天天玩天天干天天操 |