将 Excel 电子表格数据导入现有 Access DB

发布于 2024-10-11 16:29:15 字数 1310 浏览 8 评论 0原文

我设计了一个包含 3 个表的 Access 2003 DB:应用程序、服务器和安装。 APPLICATIONS 和 SERVERS 表中的记录由合成主键(在 Access 中为“自动编号”)唯一标识。 INSTALLATIONS 表本质上是应用程序和服务器之间的映射表:它是哪些应用程序安装在哪些服务器上的记录列表。 INSTALLATIONS 表中的记录也由合成主键标识,它由各自表中的记录的 APPLICATION_ID 和 SERVER_ID 组成。

我有一个 Excel 2003 电子表格,想导入到该数据库中,但事实证明这很困难。该电子表格由多个选项卡/工作表组成,每个选项卡/工作表代表一台服务器,并具有自己的已安装应用程序列表。我不确定如何继续导入 - Access 中的“获取外部数据 --> 导入”功能有一个导入“在现有表中”选项,但它呈灰色。我还不确定如何构建应用程序和服务器之间的关系以将记录导入 INSTALLATIONS 表中。

我之前曾尝试向 Access DB 文件添加一些安全性。我想我删除了所有内容,但也许我没有删除,这就是导致问题的原因?

Excel 电子表格中的一些示例数据:

SERVER101
* Adob​​e Reader 9
* BMC Remedy 用户 7.0
* HostExplorer 2008
* 微软 Office 2003
* 微软 Office 2007
* Notepad++

SERVER102
* Adob​​e Reader 9
* DameWare 迷你遥控器
* 微软 Office 2003
* 微软.NET Framework 3.5 SP1
* Oracle 9.2

SERVER103
* AWD视图
* 额外的!个人客户端 32 位
* 微软 Office 2003
* 微软.NET Framework 3.5 SP1
* 斯纳吉特 9.1
* WinZip 12.1

Access DB 设计非常简单:

应用程序
* APPLICATION_ID(自动编号)
* APPLICATION_NAME (varchar)

服务器
* SERVER_ID(自动编号)
* SERVER_NAME (varchar)

安装
* INSTALLATION_ID(自动编号)
* APPLICATION_ID(数字)
* SERVER_ID(数字)

I've designed an Access 2003 DB with 3 tables: APPLICATIONS, SERVERS, and INSTALLATIONS. Records in the APPLICATIONS and SERVERS tables are uniquely identified by a synthetic primary key (in Access, an "auto number"). The INSTALLATIONS table is essentially a mapping table between APPLICATIONS and SERVERS: it's a list of records of which applications are installed on which servers. A record in the INSTALLATIONS table is also identified by a synthetic primary key, and it consists of an APPLICATION_ID and SERVER_ID for the records in their respective tables.

I have an Excel 2003 spreadsheet I would like to import into this database, but it's proving difficult. The spreadsheet is made up of several tabs/worksheets, each one representing a server with its own listing of installed applications. I'm not sure how to proceed with an import - the "Get External Data --> Import" feature in Access has an import "In an Existing Table" option, but it's greyed out. I'm also unsure how I build the relationships between applications and servers for importing records into the INSTALLATIONS table.

I had previously fooled around with adding some security to the Access DB file. I think I removed everything but perhaps I didn't and that's causing the problem?

Some sample data from the Excel spreadsheet:

SERVER101
* Adobe Reader 9
* BMC Remedy User 7.0
* HostExplorer 2008
* Microsoft Office 2003
* Microsoft Office 2007
* Notepad++

SERVER102
* Adobe Reader 9
* DameWare Mini Remote Control
* Microsoft Office 2003
* Microsoft .NET Framework 3.5 SP1
* Oracle 9.2

SERVER103
* AWDView
* EXTRA! Personal Client 32-bit
* Microsoft Office 2003
* Microsoft .NET Framework 3.5 SP1
* Snagit 9.1
* WinZip 12.1

The Access DB design is very simple:

APPLICATION
* APPLICATION_ID (autonumber)
* APPLICATION_NAME (varchar)

SERVER
* SERVER_ID (autonumber)
* SERVER_NAME (varchar)

INSTALLATION
* INSTALLATION_ID (autonumber)
* APPLICATION_ID (number)
* SERVER_ID (number)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

待"谢繁草 2024-10-18 16:29:16

如果导入到现有表不起作用,我建议将“获取外部数据 --> 导入”中的数据导入到新表中。然后,运行 INSERT INTO 查询以根据需要将数据插入到表中。

如果您以这种方式导入它们,则必须对每个工作表执行一次导入。

如果您发布一些结构数据,那么我也许可以帮助处理应用程序和服务器之间的关系。

编辑:SQL 查询

因此,要将应用程序导入到 APPLICATION 表中,首先进行查询:

SELECT *
FROM [SERVER101]
UNION
SELECT *
FROM [SERVER102]
UNION
SELECT *
FROM [SERVER103]

然后运行 ​​INSERT INTO:

INSERT INTO
[APPLICATION] (APPLICATION_NAME)
FROM [Query] ([Field Name])

要填充 INSTALLATION 表,为每个服务器使用一个表,您实际上不需要需要很多加入。
对于 SERVER101 表,我认为可行的是:

INSERT INTO
[INSTALLATION] (APPLICATION_ID, SERVER_ID, ?other fields?)
FROM [APPLICATION] (APPLICATION_ID, 101, ?other fields?)
INNER JOIN [SERVER101]
ON [SERVER101].[Application Name] = [APPLICATION].[APPLICATION_NAME]

我只会在 SERVER 表上进行数据输入,除非您有一个单独的电子表格来描述服务器。

If importing into an existing table isn't working, I would recommend importing the data from "Get External Data --> Import" into a new table. Then, run an INSERT INTO query to insert the data into your tables as needed.

You will have to do one import per worksheet, if you import them this way.

If you post some structural data then I may be able to help with the relationships between applications and servers.

EDIT: SQL Queries

So to import the Applications into the APPLICATION Table, first make a query:

SELECT *
FROM [SERVER101]
UNION
SELECT *
FROM [SERVER102]
UNION
SELECT *
FROM [SERVER103]

Then run INSERT INTO:

INSERT INTO
[APPLICATION] (APPLICATION_NAME)
FROM [Query] ([Field Name])

To populate the INSTALLATION table, working with a table for each server, you really don't need many joins.
Here's what I think would work, for the SERVER101 table:

INSERT INTO
[INSTALLATION] (APPLICATION_ID, SERVER_ID, ?other fields?)
FROM [APPLICATION] (APPLICATION_ID, 101, ?other fields?)
INNER JOIN [SERVER101]
ON [SERVER101].[Application Name] = [APPLICATION].[APPLICATION_NAME]

And I would just do data entry on the SERVER table, unless you have a separate spreadsheet describing the servers.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文