简体   繁体   English

从现有的 MS Access 表自动生成 SQL

[英]Automatically Generate SQL from existing MS Access table

I've just designed a large database by playing around in MS Access.我刚刚通过使用 MS Access 设计了一个大型数据库。 Now that I'm happy with the design, I need to be able to generate this same database (tables, relationships, etc.) from code.现在我对设计感到满意,我需要能够从代码生成相同的数据库(表、关系等)。

Rather than hand-writing the SQL CREATE statements (which will be long, tedious, and error-prone process), I was wondering whether there was a shortcut.与其手写 SQL CREATE 语句(这将是漫长、乏味且容易出错的过程),我想知道是否有捷径。 I seem to recall from my limited exposure to MySql that I was able to export an entire database as an SQL statement that can then be run in order to regenerate that database.我似乎回忆起我对 MySql 的有限接触,我能够将整个数据库导出为 SQL 语句,然后可以运行该语句以重新生成该数据库。

Do you know of a way to do this in MS Access, either through the GUI, or programmatically?您知道通过 GUI 或以编程方式在 MS Access 中执行此操作的方法吗?

I just found and tried out this tool: jet-tool .我刚刚找到并试用了这个工具: jet-tool It seems to work well for Access 2010.它似乎适用于 Access 2010。

The quick and dirty, easy, perfectly legitimate way to do this is just copy the .mdb file.快速、肮脏、简单、完全合法的方法就是复制 .mdb 文件。 Empty out the data if you need to - usually there are static tables that are handy to leave populated, however.如果需要,请清空数据 - 然而,通常有静态表可以方便地填充。

免费 30 天(然后是 30 美元),您可以试一试 DBWScript ,看起来就像您要的那样,尽管不是在本机 Access GUI 中或以编程方式

I use a free utility called MDB Viewer Plus ( http://www.alexnolan.net/software/mdb_viewer_plus.htm ).我使用名为 MDB Viewer Plus ( http://www.alexnolan.net/software/mdb_viewer_plus.htm ) 的免费实用程序。 Launch it, open your db, then select your table.启动它,打开你的数据库,然后选择你的表。 On top menu, select "Table > Generate SQL - CREATE".在顶部菜单上,选择“表 > 生成 SQL - CREATE”。

I don't know what tools you have on your development machine, so this may or may not be helpful.我不知道你的开发机器上有什么工具,所以这可能有帮助,也可能没有帮助。

You can easily transfer your Access database to Microsoft SQL Server using the Upsizing Wizard .您可以使用升迁向导轻松地将 Access 数据库传输到 Microsoft SQL Server。

The express edition of SQL Server is available for free > here . SQL Server 的 Express 版本可免费使用 > 点击此处

You will also want to get the free Management Studio Express .您还需要获得免费的Management Studio Express

Using these free graphical-based tools you can easily generate the SQL statements to re-create the database.使用这些免费的基于图形的工具,您可以轻松生成 SQL 语句以重新创建数据库。 You will have the Create statements you are looking for and they will be placed in a text file.您将拥有您正在寻找的 Create 语句,它们将被放置在一个文本文件中。

The Bullzip is very good to this. Bullzip 对此非常满意。 Very simple.很简单的。 See bullzip Access to MySQL for example例如,参见Bullzip Access to MySQL

It is possible export any tables to SQL or migrate automatically.可以将任何表导出到 SQL 或自动迁移。

Access to MySQL is a small program that will convert Microsoft Access Databases to MySQL. Access to MySQL 是一个将 Microsoft Access 数据库转换为 MySQL 的小程序。

  • Wizard interface.向导界面。
  • Transfer data directly from one server to another.将数据直接从一台服务器传输到另一台服务器。
  • Create a dump file.创建转储文件。
  • Select tables to transfer.选择要传输的表。
  • Select fields to transfer.选择要传输的字段。
  • Transfer password protected databases.传输受密码保护的数据库。
  • Supports both shared security and user-level security.支持共享安全和用户级安全。
  • Optional transfer of indexes.可选的索引传输。
  • Optional transfer of records.可选的记录传输。
  • Optional transfer of default values in field definitions.字段定义中默认值的可选传输。
  • Identifies and transfers auto number field types.识别和传输自动编号字段类型。
  • Command line interface.命令行界面。
  • Easy install, uninstall and upgrade.易于安装、卸载和升级。

The thing that you're mentioning in MySQL is sql dumping.您在 MySQL 中提到的事情是 sql 转储。 Very useful feature.非常有用的功能。 If you want to migrate the database to mysql, here's a helpful article.如果您想将数据库迁移到 mysql,这里有一篇有用的文章。

http://www.kitebird.com/articles/access-migrate.html#TOC_4 http://www.kitebird.com/articles/access-migrate.html#TOC_4

I have been using for years a tool called database.net from https://fishcodelib.com/Database.htm我多年来一直使用来自https://fishcodelib.com/Database.htm 的名为database.net的工具
I generally use it on client's site as a portable version of SSMS (drop and run), but it can handle a multitude of RDBMSes, including Access.我通常在客户端站点上使用它作为 SSMS(即放即用)的便携式版本,但它可以处理多种 RDBMS,包括 Access。
Connect to your mdb/accdb, right click any table, choose SCRIPT AS, Create, and you're done.连接到您的 mdb/accdb,右键单击任何表,选择 SCRIPT AS,创建,然后就完成了。
If you right click Tables header, you can select multiple tables to generate, but I think it's a feature of the paid version.如果右击表头,可以选择多张表生成,不过我觉得是付费版的一个功能。
I have no acquaintance with them, just a happy client.我不认识他们,只是一个快乐的客户。

I found an easy way to go:我找到了一个简单的方法:

Export-> ODBC Database导出-> ODBC 数据库

and then retrieve the SQL form there (eg via pgadmin on postgres)然后在那里检索 SQL 表单(例如通过 postgres 上的 pgadmin)

Compare'Em http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htm免费版创建 VBA,而 10 美元的专业版为您提供 DDL 语句。

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

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