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中保留单个数据的正确方法?
基础教程推荐
- SQL 效率:WHERE IN 子查询 vs. JOIN 然后 GROUP 2021-01-01
- SQL Server 实例在登录协商期间返回无效或不受支持的协议版本 2021-01-01
- 需要 MySQL 5.1 中的抽象触发器来更新审计日志 2021-01-01
- 如何使用 mysql.connector 禁用查询缓存 2022-01-01
- SQL:使用来自具有相同列名的两个表中的数据... 2021-01-01
- SSMS 中的权限问题:“对象 'extended_properties'、数据库 'mssqlsystem_resource'、... 错误 229)上的 SELECT 权限被拒绝" 2022-01-01
- 无法解决整理冲突 2021-01-01
- 是否可以执行按位分组功能? 2021-01-01
- 将 SQL Server DateTime 列迁移到 DateTimeOffset 2021-01-01
- 在 SQL 中连接多个表 2021-01-01
