Proper way to keep a single data in sql server?(在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中保留单个数据的正确方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在sql server中保留单个数据的正确方法?


- 更改自动增量起始编号? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01