简体   繁体   English

保持MS-Access和SQL Server之间的数据库结构兼容

[英]Keeping database structure compatible between MS-Access and SQL Server

I'm working on a legacy project, written for the most part in Delphi 5 before it was upgraded to Delphi 2007. A lot has changed after this upgrade, except the database that's underneath. 我正在做一个旧项目,在升级到Delphi 2007之前,大部分时间都是用Delphi 5编写的。此次升级后,除了下面的数据库外,很多事情都发生了变化。 It still uses MS-Access for data storage. 它仍然使用MS-Access进行数据存储。

Now we want to support SQL Server as an alternate database. 现在我们要支持SQL Server作为备用数据库。 Still just for single-user situations, although multi-user support will be a feature for the future. 尽管多用户支持将成为未来的功能,但仍仅适用于单用户情况。 And although there won't be many migration problems (see below) when it needs to use a different database, keeping two database structures synchronized is a bit of a problem. 而且,当它需要使用不同的数据库时,不会有很多迁移问题(请参阅下文),但是保持两个数据库结构同步是一个问题。

If I would create an SQL script to generate the SQL Server database then I would need a second script to keep the Access database up-to-date too. 如果我要创建一个SQL脚本来生成SQL Server数据库,那么我还需要第二个脚本来使Access数据库保持最新。 They don't speak the same dialect. 他们讲不同的方言。 (At least, not for our purposes.) So I need a way to maintain the database structure in a simple way, making sure it can generate both a valid SQL Server database as an Access database. (至少,不是出于我们的目的。)因此,我需要一种以简单的方式维护数据库结构的方法,以确保它可以生成有效的SQL Server数据库和Access数据库。 I could write my own tool where I store the database structure inside an XML file, which combined with some smart code and ADOX would generate both database types. 我可以编写自己的工具,将数据库结构存储在XML文件中,再结合一些智能代码和ADOX即可生成这两种数据库类型。

But isn't there already a good tool that can do this? 但是,已经没有一个好的工具可以做到这一点吗?


Note: the application also uses ADO and all queries are just simple select statements. 注意:应用程序还使用ADO,所有查询都只是简单的select语句。 Although it has 50+ tables, there's one root "Document" table and the user selects one of the "documents" in this table. 尽管它有50多个表,但是有一个根“文档”表,用户可以在此表中选择一个“文档”。 It then collects all records from all tables that are related to this document record and stores them in an in-memory structure. 然后,它从与此文档记录相关的所有表中收集所有记录,并将它们存储在内存结构中。 When the user saves the data, it just writes the document record and all changed data back to the database again. 当用户保存数据时,它只是将文档记录和所有更改的数据再次写回到数据库中。 Basically, this read/write mechanism of documents is the only database interaction in the whole application. 基本上,文档的这种读/写机制是整个应用程序中唯一的数据库交互。 So using a different database is not a big problem. 因此,使用其他数据库不是一个大问题。

We will drop the MS-Access database in the future but for now we have 4000 customers using this application. 我们将来会删除MS-Access数据库,但目前有4000个客户使用此应用程序。 We first need to make sure the whole thing works with SQL Server and we need to continue to maintain the current code. 我们首先需要确保整个事情都可以在SQL Server中使用,并且我们需要继续维护当前代码。 As a result, we will have to support both databases for at least a year. 结果,我们将必须同时支持这两个数据库至少一年。

Take a look at the DB Explorer , there is a trial download too. 看一下DB Explorer ,也有一个免费下载。

OR 要么

  1. Use migration wizard from MS Access to SQL Server 使用从MS Access到SQL Server的迁移向导
  2. After development in Access (schema changes), use the wizard again. 在Access中开发(模式更改)之后,再次使用向导。
  3. Use a tool to compare SQL Server schemata. 使用工具比较SQL Server模式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM