English 中文(简体)
提出可读性/可维持性的长期询问
原标题:Splitting up long queries for readability / maintainability

我继承了一个访问数据库,该数据库有50个栏目。 即便在MS Access图像查询设计工具中,它也为海事组织提供了太多的信息。

一位快速的否认者——我有方案规划背景,但几乎没有数据库经验。

For this particular problem, I need data from 50+ columns. Is there a better way to get this information than one huge query?

我对如何开展工作感到有点损失。 网上的共识似乎是,应当保持比较小的、格式好的方式。 当你需要这么多的领域时,我看不出如何适用这一原则。 Can 我用许多简单的问询与一个UNION或INSERT INTO临时表格进行? 任何建议或RTFM?

EDIT: 更多应用。 数据分布在14个表格中。 I m grabbing the data to written it out to an external file which has 50 + areas per row (think CSV edition of a distributionsheet).

EDIT: Managing and debugging SQL queries in MS Access looks like it contains relevant advice.

最佳回答

I think you re worrying yourself over nothing at all. Pulling 50 fields from 14 tables in order to output to a flat file is nothing at all. The point is that you re intentionally denormalizing data because you need a flat-file output. By definition, that will mean lots of columns.

As others have said, 50 columns in one table would be out of the ordinary (though not necessarily a design error), but in the situation you describe, I don t see an issue at all.

简言之,它像一个完美的罚款一样,我不得不问,什么是你认为它是一个问题。

问题回答

我赞同关于每次需要50+栏的多数意见。

然而,如果把引起你的悲痛的50+栏带上了问询的灯光,你可以提出这种看法。 不能排除以下事实,即你处理数据bu,但它可以概括地概括地概括说一片大、一发。

如果你从所有栏目中检索数据,你可以写上<条码>。

如果在单一表格中有50列栏,数据库的设计最好有问题。 这实际上可能意味着,你只得应付非强权的解决办法。

你们是否真正需要所有数据? 如果不是的话,它可能比照<代码>SlectT。 您在特定时间需要的数据。 你们应当提供更多有关实际任务的信息。

如果你的数据来自多个表格,你可使用Common Table expressions,将询问分为小组。





相关问题
SQL SubQuery getting particular column

I noticed that there were some threads with similar questions, and I did look through them but did not really get a convincing answer. Here s my question: The subquery below returns a Table with 3 ...

难以执行 REGEXP_SUBSTR

I m 查询Oracle 10g。 我有两张表格(样本数据见下文)。 i m 试图提取一些领域

SQL Query Shortcuts

What are some cool SQL shorthands that you know of? For example, something I learned today is you can specify to group by an index: SELECT col1, col2 FROM table GROUP BY 2 This will group by col2

PHP array callback functions for cleaning output

I have an array of output from a database. I am wondering what the cleanest way to filter the values is example array Array ( [0] => Array ( [title] => title 1 ...

OracleParameter and DBNull.Value

we have a table in an Oracle Database which contains a column with the type Char(3 Byte). Now we use a parameterized sql to select some rows with a DBNull.Value and it doesn t work: OracleCommand ...

Running numbers in SQL

I have a SQL-statement like this: SELECT name FROM users WHERE deleted = 0; How can i create a result set with a running number in the first row? So the result would look like this: 1 Name_1 2 ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签