48

sql – 为什么位置查询不好?

 5 years ago
source link: https://codeday.me/bug/20190112/509316.html?amp%3Butm_medium=referral
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
我正在阅读CJ Date的 SQL and Relational Theory: How to Write Accurate SQL Code

,他认为位置查询很糟糕 – 例如,这个INSERT:

INSERT INTO t VALUES (1, 2, 3)

相反,您应该使用这样的基于属性的查询:

INSERT INTO t (one, two, three) VALUES (1, 2, 3)

现在,我理解第一个查询与关系模型不一致,因为元组(行)是无序的属性集(列).我无法理解第一个查询中的伤害位置.谁可以给我解释一下这个?

每次表架构更改时,第一个查询都会中断.第二个查询适应任何架构更改,使其列保持原样并且不添加无默认列.

由于同样的原因,执行SELECT *查询然后依靠位置表示法来提取他们关注的值的人是 software maintenance supervillains .

翻译自:https://stackoverflow.com/questions/1082956/why-are-positional-queries-bad


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK