我看到了一些用来克服服务器中缺乏固定机的规律,但其中没有一个似乎满足了性能和可读性/可维持性的关切。
在以下例子中,假设我们在桌上有一个整体地位分类,选择似乎如下:
- Just to hard code it, and possibly just comment the status
-- StatusId 87 = Loaded
SELECT ... FROM [Table] WHERE StatusId = 87;
- Using a lookup table for states, 之后joining to this table so that the
WHERE
clause references the friendly name.
www.un.org/Depts/DGACM/index_spanish.htm 质量:
SELECT ...
FROM [Table]
WHERE
StatusId = (SELECT StatusId FROM TableStatus WHERE StatusName = Loaded );
<>0>
SELECT ...
FROM [Table] t INNER JOIN TableStatus ts On t.StatusId = ts.StatusId
WHERE ts.StatusName = Loaded ;
- A bunch of scalar UDF s defined which return constants, viz
CREATE Function LoadedStatus()
RETURNS INT
AS
BEGIN
RETURN 87
END;
之后
SELECT ... FROM [Table] WHERE StatusId = LoadedStatus();
(海事组织在数据库中造成大量污染,这可能是Oracle包裹中的K)
- And similar patterns with Table Valued Functions holding the constants with values as rows or columns, which are
CROSS APPLIED
back to[Table]
其他SO用户如何解决这一共同问题?
http://www.ohchr.org。 Bounty - 是否有任何最佳实践方法,根据Remus的答复和评论,在非洲开发银行/Schema书写中维持(变量)美元?