在sql server中保留单个数据的正确方法?

时间:2023-02-07
本文介绍了在sql server中保留单个数据的正确方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

我有一个包含很多列和行的表 (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 的目的

它充当标识号,但不像主键那样创建.一个例子(之前和之后):

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中保留单个数据的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

上一篇:TSQL:调整动态查询搜索 下一篇:如何更改字符串中的大小写

相关文章

最新文章