29

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.

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.

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

curtisk
  • 19,950
  • 4
  • 55
  • 71
Smashery
  • 57,848
  • 30
  • 97
  • 128
  • 1
    I have previously written some notes in http://stackoverflow.com/questions/698839/how-to-extract-the-schema-of-an-access-mdb-database/699516#699516 – Fionnuala Aug 02 '13 at 13:56

10 Answers10

12

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

jpmc26
  • 28,463
  • 14
  • 94
  • 146
6

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

curtisk
  • 19,950
  • 4
  • 55
  • 71
5

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.

dkretz
  • 37,399
  • 13
  • 80
  • 138
  • 1
    +1 - Hehe - hadn't really considered that. Funny how the simplest solutions are often the ones you overlook. Unfortunately, our product may be released as a standalone executable, so probably not plausible in this case. Although I guess we could somehow embed the binary data in the exe... – Smashery Apr 17 '09 at 02:13
4

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

Niente0
  • 504
  • 3
  • 11
  • This worked well for me, thank you. As a side note, for some reason you cannot download the MDB Viewer Plus directly from Alex Nolan's website. It is available on several public software archives. – Myrddin Emrys Jun 25 '17 at 17:05
  • Bad news. I downloaded MDB Viewer Plus Version 2.63 and the option "Table > Generate SQL - CREATE" is missing. – villamejia Oct 30 '20 at 14:56
  • 1
    You can find v.2.52 here: http://s000.tinyupload.com/index.php?file_id=00286856232743084617. This version still has the export option. – Niente0 Nov 03 '20 at 09:27
4

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.

The express edition of SQL Server is available for free > here.

You will also want to get the free 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.

TheSoldier
  • 484
  • 1
  • 5
  • 25
JonnyBoats
  • 5,177
  • 1
  • 36
  • 60
3

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

It is possible export any tables to SQL or migrate automatically.

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.
Pang
  • 9,564
  • 146
  • 81
  • 122
Davi Menezes
  • 507
  • 1
  • 5
  • 10
2

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.

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

putolaruan
  • 2,084
  • 2
  • 21
  • 32
0

I have been using for years a tool called database.net from 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.

iDevlop
  • 24,841
  • 11
  • 90
  • 149
0

I found an easy way to go:

Export-> ODBC Database

and then retrieve the SQL form there (e.g via pgadmin on postgres)

Raff
  • 1
-1

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

Tony Toews
  • 7,850
  • 1
  • 22
  • 27