問題描述
我有一個包含很多列和行的表 (myData),并有另一個表 (myFileNo) 單值,這意味著單行、單列、單單元格 (FileNo),
I have a table (myData) with lots of columns and rows, and have another table (myFileNo) single value which means single row, single column, single cell (FileNo),
我寫了一個 sql 查詢,它通過檢查 myFileNo 更新 myData,并在進程結束后更改 FileNo 的值.
I wrote an sql query which updates myData by checking myFileNo, and after process ends it changes the value of FileNo.
將單值數據保存在表中對我來說沒有多大意義,這是正確的做法嗎?
It does not make much sense to me to keep the single value data in a table, is this the proper way to do it ?
FileNo 的目的
它充當標識號,但不像主鍵那樣創(chuàng)建.一個例子(之前和之后):
It acts as an identification number, but not created like a primary key. An example (before, and after):
之前
myData, FileNo
A, NULL
A, NULL
B, NULL
C, NULL
A, NULL
D, NULL
D, NULL
文件編號:15
之后
myData, FileNo
A, 16
A, 16
B, 17
C, 18
A, 16
D, 19
D, 19
FileNo: 19
推薦答案
如果 fileNo 被多個表和進程引用,然后將其存儲在一個表中就可以了,您可以調查擴展屬性,但我會保留放在桌子上.
In the case that the fileNo is being referenced by multiple tables and processes then storing it in a table is fine, you could investigate extended properties, but I would keep it in a table.
如果你只需要這個表并且你只需要能夠識別下一次加載的最大值+1,我建議你在插入之前檢查Max(FileNo),前提是這不會導致性能問題,基于表的大小.
If you only need it for this table and you only need to be able to identify the maximum value + 1 for the next load, I suggest you just check Max(FileNo) before inserting, providing this does not cause performance issues, based on the size of the table.
這篇關于在sql server中保留單個數據的正確方法?的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!