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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/758669/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-01 01:45:09  来源:igfitidea点击:

Automatically Generate SQL from existing MS Access table

sqlms-accessschema

提问by Smashery

I've just designed a large database by playing around in 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.

我刚刚通过使用 MS Access 设计了一个大型数据库。现在我对设计感到满意,我需要能够从代码生成相同的数据库(表、关系等)。

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. 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.

与其手写 SQL CREATE 语句(这将是漫长、乏味且容易出错的过程),我想知道是否有捷径。我似乎回忆起我对 MySql 的有限接触,我能够将整个数据库导出为 SQL 语句,然后可以运行该语句以重新生成该数据库。

Do you know of a way to do this in MS Access, either through the GUI, or programmatically?

您知道通过 GUI 或以编程方式在 MS Access 中执行此操作的方法吗?

采纳答案by curtisk

For free for 30 days (then $30) you can give DBWScripta go, looks like its what you are asking for, although not in native Access GUI or programmatically

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

回答by jpmc26

I just found and tried out this tool: jet-tool. It seems to work well for Access 2010.

我刚刚找到并试用了这个工具:jet-tool。它似乎适用于 Access 2010。

回答by dkretz

The quick and dirty, easy, perfectly legitimate way to do this is just copy the .mdb file. Empty out the data if you need to - usually there are static tables that are handy to leave populated, however.

快速、肮脏、简单、完全合法的方法就是复制 .mdb 文件。如果需要,请清空数据 - 然而,通常有静态表可以方便地填充。

回答by JonnyBoats

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. You will have the Create statements you are looking for and they will be placed in a text file.

使用这些免费的基于图形的工具,您可以轻松生成 SQL 语句以重新创建数据库。您将拥有您正在寻找的 Create 语句,它们将被放置在一个文本文件中。

回答by Niente0

I use a free utility called 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".

我使用名为 MDB Viewer Plus ( http://www.alexnolan.net/software/mdb_viewer_plus.htm)的免费实用程序。启动它,打开你的数据库,然后选择你的表。在顶部菜单上,选择“表 > 生成 SQL - CREATE”。

回答by Davi Menezes

The Bullzip is very good to this. Very simple. See bullzip Access to MySQLfor example

Bullzip 对此非常满意。很简单。例如,参见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.

  • 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.

Access to MySQL 是一个将 Microsoft Access 数据库转换为 MySQL 的小程序。

  • 向导界面。
  • 将数据直接从一台服务器传输到另一台服务器。
  • 创建转储文件。
  • 选择要传输的表。
  • 选择要传输的字段。
  • 传输受密码保护的数据库。
  • 支持共享安全和用户级安全。
  • 可选的索引传输。
  • 可选的记录传输。
  • 字段定义中默认值的可选传输。
  • 识别和传输自动编号字段类型。
  • 命令行界面。
  • 易于安装、卸载和升级。

回答by putolaruan

The thing that you're mentioning in MySQL is sql dumping. Very useful feature. If you want to migrate the database to mysql, here's a helpful article.

您在 MySQL 中提到的事情是 sql 转储。非常有用的功能。如果您想将数据库迁移到 mysql,这里有一篇有用的文章。

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

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

回答by Patrick Honorez

I have been using for years a tool called database.netfrom https://fishcodelib.com/Database.htm
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.
Connect to your mdb/accdb, right click any table, choose SCRIPT AS, Create, and you're done.
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.

多年来,我一直在使用https://fishcodelib.com/Database.htm 中名为database.net的工具, 我通常在客户端站点上将它用作 SSMS(即放即用)的便携式版本,但它可以处理多种RDBMS,包括访问。 连接到您的 mdb/accdb,右键单击任何表,选择 SCRIPT AS,创建,然后就完成了。 如果右击Tables header,可以选择多张表生成,不过我觉得是付费版的一个功能。 我不认识他们,只是一个快乐的客户。



回答by Tony Toews

Compare'Em http://home.gci.net/~mike-noel/CompareEM-LITE/CompareEM.htmThe free version creates VBA while the $10 pro version gives you DDL statements.

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