将多个Access DB(功能相同但数据不同)迁移到单个SQL Server DB

发布于 2024-11-24 09:11:44 字数 792 浏览 2 评论 0原文

情况

我有 5 个 Access DB 文件,每个文件都有 10 个表、40 个查询和 8 个宏。所有 5 个 Access DB 文件具有相同的表名、表结构、相同的查询和相同的宏。唯一的不同是表中包含的数据。如果重要的话,每个数据库上的某些表的行数在几百到 100K+ 之间。

我想要实现的目标

我正在将这 5 个 Access DB 文件迁移到单个 SQL Server (2008) 数据库。 编辑:迁移后,我确实需要知道哪些表属于哪个数据库,因为每个原始 Access DB 都与公司的部门相关联,因此我需要对此进行跟踪。

我的解决方案或选项

表将作为表导入到 SQL Server。查询将作为存储过程导入。宏将作为新的存储过程导入。

  1. 将每个 Access DB 的表和查询导入到 SQL Server DB,并通过给定前缀来重命名每个表和查询,以识别哪些表属于哪个数据库。
  2. 但与 #1 相同,仅导入表。至于查询,仅导入一组查询(40 个查询)并修改它们以从表中动态选择、插入、更新或删除。
  3. 将第一个 Access DB 中的表 A、第二个 Access DB 中的表 A、第三个 Access DB 中的表 A 等导入到 SQL Server 中的一个新表中,并为它们提供唯一标识符以标识哪一行数据属于哪个数据库。

您认为最好的方法是什么?请告诉我是否有比我列出的更好的方法来做到这一点。谢谢!

Situation

I have 5 Access DB files, each one has 10 tables, 40 queries and 8 macros. All 5 Access DB files have same table name, table structure, same queries and same macros. The only different is the data contain in the table. If it matters, some tables on each database has rows between few hundreds to 100K+.

What I am trying to achieve

I am migrating these 5 Access DB files to single SQL Server (2008) database. Edit: After migrating, I do need to know which tables belong to which database since each original Access DB is associated with company's department so I need to keep track of this.

My Solutions or Options

Tables will be imported to SQL Server as tables. Queries will be imported as Stored Procedures. Macro will be imported as new Stored Procedures.

  1. Import each Access DB's tables and queries to SQL Server DB and rename each tables and queries by giving them prefix to identify which tables belong to which database.
  2. Same as #1, however, only import tables. As for the queries, only import one set of queries (40 queries) and modify them to dynamically select, insert, update or delete from the tables.
  3. Import table A from 1st Access DB, table A from 2nd Access DB, table A from 3rd Access DB and so on, to one new table in SQL Server and give them unique identifier to identify which row of data belong to which database.

What do you think is the best approach? Please tell me if there is better way to do this than what I have listed. Thanks!

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

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

发布评论

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

评论(3

芸娘子的小脾气 2024-12-01 09:11:44

我会将它们迁移到 MS SQL,如下所示:

  • 将数据库 1 中的所有表导入 SQL Server 中的相应表,但添加一个具有旧主键名称的新主键,重命名旧的 pk 和数据库标识符。
  • 使用旧的 pk 和标识符将所有外键更新为新的 pk 字段。
  • 对数据库重复 2-5
  • 删除标识符或保留它,具体取决于您是否需要知道行来自何处​​(旧主键相同)
  • 仅导入查询/宏一次,因为它们是相同的。

当这样做时,您可以保持 pk-fk 关系和查询完整,并且仍然知道行来自哪里。

I would migrate them to MS SQL like so:

  • Import all tables from database 1 into corresponding tables from SQL Server, but add a new primary key with the name of the old one, rename the old pk and identifier for the database.
  • Update all foreign keys to the new pk field using the old pk and the identifier.
  • Repeat for databases 2-5
  • Either delete the identifier or keep it, depending if you need to know where the rows came from (same for old primary keys)
  • Only import queries/macros once, as they are the same.

When doing it this way, you keep the pk-fk relations and the queries intact and still know where the rows came from.

宣告ˉ结束 2024-12-01 09:11:44

我想说的是第三点。你不会得到重复的代码并且更容易维护。

更容易维护的一个例子是性能调整。您说 5 个访问数据库中的查询是相同的:假设您检测到其中一个查询运行速度太慢,并且您决定需要在基础表上创建索引。在选项 #1 和 #2 中,这意味着在 5 个“孪生”表上重新创建相同的索引。

I would say number 3. You would get no duplication code and much easier maintenance.

One example of easier maintenance is performance tuning. You say the queries are the same in the 5 access DBs: say you detect one of the queries runs too slow and you decide that you need to create an index on an underlying table. In option #1 and #2 this would mean recreating the same index on 5 "twin" tables.

相对绾红妆 2024-12-01 09:11:44

在访问每个数据库时,您可以为每个部门字段 id(新字段)分配新表中的标识符(每个部门有不同的值),然后将此值添加到要访问的每个表中。被进口。创建一个包含部门信息的新表,然后创建连接这些表的联接表。因此,每个部门之间都是有区别的。

In access for each of these databases, you could assign each of the department field id (new field) with it's on identifier in a new table (each department has different value), and then add this value to each of the tables that is to be imported. Create a new table that has the department information in it, then create join table that connect these tables. Thus, each department is differentiated between each other.

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