tags:

views:

150

answers:

5

Initialization would include creating all the required tables, constraints and populating the tables.

edit: Is there already a project doing this?

+1  A: 

Create a script that is either part of of the end of your database creation script, or runs after it.

It may typically contain a lot of insert statements to populate reference tables, or similar.

Galwegian
A: 

You could take it a step further and write a script to load in a text file.

In this text file you could set up some default styling and then use your script to handle it, for example:

tb_newTable
id pk
name vc 255
email vc 255
-end

Or something. So your handler reads this, recognises tb_ to be table name, then on line by line basis it creates the fields, so id pk could field name id, and primary key, name vc 255 is field called name at varchar 255 etc.. with -end stopping it.

This is theoreticaly mind, and the above won't do squat but it migth give you an idea.

This is exactly what I was trying to do. It seems unreal that there are currently no projects to transfer, say, an XML schema (eg. hibernate) to a database so that we stay database (SQL) independent.Perhaps this shall be the birth of one.
sandesh247
A: 

I don't know about specific tools for other databases, but mysqldump does exactly this for MySQL.

warren
A: 

If you use MySQL there is a command called MySQLDump. This outputs a copy of a database as a series of text SQL statements to create the tables and fill them with data.

So, you use MySQLDump to create a backup of your working database, then you simply execute the resulting file on your empty database to create and populate it.

The doc can be found here... http://dev.mysql.com/doc/refman/5.0/en/mysqldump.html

rikh
A: 

Since yu mention .net as a tag you may be using MSSQL.

If you have VS.NET db edition you can use the database tools to generate scripts for this. You can do schema comparer against a blank database and generate the script for the schema. You can then do the same for the data.

If not there are tools you can get to do this for you. Such as http://sqlmanager.net/en/products/dbextract .

There are other tools as well for this, unfortunately that I cant think of off the top of my head as I use the former mentioned.

mattlant