English 中文(简体)
服务器2008年——虚射栏值——应当使用无效或空洞吗?
原标题:SQL Server 2008 - Default column value - should i use null or empty string?

一段时间内,如果一栏中一栏不知数据是否会通过,将数据的价值确定为空洞(......)或仅允许无效,则一刀切。

我谨在此听取所建议的做法。

如果情况不同,则使用C#作为消费申请。

最佳回答

我害怕......

it depends!

这一问题没有单一的答案。

如其他答复所示,NUL和空洞中具有非常不同的语义:,前者表示该数值不详,后者表示该数值为“无形物品”(显示和报告),但“已知价值”并不多。 这方面常见的一个例子是中名。 “中间——名称”一栏中的无效价值将表明,我们不知道底人是否拥有中间名称,如果是,空洞将表明,此人的“知道”不是“。

也就是说,另外两种因素可能有助于你选择这些选择,一栏。

  • The very semantics of the underlying data, at the level of the application.
  • Some considerations in the way SQL works with null values

Data semantics
For example it is important to know if the empty-string is a valid value for the underlying data. If that is the case, we may loose information if we also use empty string for "unknown info". Another consideration is whether some alternate value may be used in the case when we do not have info for the column; Maybe n/a or unspecified or tbd are better values.

SQL behavior and utilities
Considering SQL behavior, the choice of using or not using NULL, may be driven by space consideration, by the desire to create a filtered index, or also by the convenience of the COALESCE() function (which can be emulated with CASE statements, but in a more verbose fashion). Another consideration is whether any query may attempt to query multiple columns to append them (as in SELECT name + , + middle_name AS LongName etc.).

除了在具体情况中选择“民族解放军”和“空洞”的做法的有效性外,一般认为它要尽可能地尝试和一致,即尝试和坚持一种特定的方式,并且仅仅/有目的/明确地出于良好的理由和少数情况偏离这种方式。

问题回答

如果无价值,则不使用空洞。 如果你需要知道某项价值是否为不知,就要有旗帜。 但10次中有9次没有提供资料,但资料不明确,罚款。

<代码>NUL系指未知值。 空洞是指一种已知的价值,即长度为零。 这些是完全不同的。

当我想要一个有效的缺省值,例如用户的中间名称可能不会改变时,空洞。

如果随后的法典没有明确确定价值,则构成错误。

然而, 通过采用具有就业价值而不是无效的扼杀手段,你可以减少发生“不考虑”的可能性。

我倾向于认为:

  • Empty string as a known value
  • NULL as unknown

在此情况下,我很可能使用NUL。

一个重要事情是前后一致的:混淆联合国利比里亚特派团和空洞将最终消失。

在实际执行方面,空洞在服务器中需要2台 by,而作为NULs正在编组。 在某些条件下,对于大型/大型的表格来说,由于它增加了数据,因而在业绩方面有所不同。





相关问题
Simple JAVA: Password Verifier problem

I have a simple problem that says: A password for xyz corporation is supposed to be 6 characters long and made up of a combination of letters and digits. Write a program fragment to read in a string ...

Case insensitive comparison of strings in shell script

The == operator is used to compare two strings in shell script. However, I want to compare two strings ignoring case, how can it be done? Is there any standard command for this?

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

String initialization with pair of iterators

I m trying to initialize string with iterators and something like this works: ifstream fin("tmp.txt"); istream_iterator<char> in_i(fin), eos; //here eos is 1 over the end string s(in_i, ...

break a string in parts

I have a string "pc1|pc2|pc3|" I want to get each word on different line like: pc1 pc2 pc3 I need to do this in C#... any suggestions??

Quick padding of a string in Delphi

I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "...

热门标签