rexdefuror
rexdefuror

Reputation: 583

Create database from DDL script

Ok, this might be bit silly question but I can't seem to find any viable reference to what I need.

I'm going through NHibernate tutorial and with code I got this DDL scripted database. I know few facts on DDL but never worked with it to be honest. So I have no idea how to create a database from it on my server. Of course, I've just tried running it but nothing happens (as expected eh...).

Note: I'm running SQL Server 2012.

Please do help even if this might be too stupid to ask.

Thanks.

Upvotes: 3

Views: 13737

Answers (3)

shakram02
shakram02

Reputation: 11886

if you want the script that creates the database, it should be on this format

CREATE TABLE <table name> ( 
    <attribute name 1> <data type 1>,
    ...
    <attribute name n> <data type n>
    );
  • replace the angle brackets AND its content entirely with your values*

reference: http://www.tomjewett.com/dbdesign/dbdesign.php?page=ddldml.php best of luck :)

Upvotes: 1

user3097189
user3097189

Reputation: 1

This may sound dumb, but I recently did something very similar in mssqlmm and was quite confused as to why I could not find the new created database from the script I had just run. Turns out I just had to click the refresh button on the left hand pane before it showed up in the databases tree.

Upvotes: 0

ruakh
ruakh

Reputation: 183514

"DDL" stands for "Data Definition Language"; it's a blanket term for SQL statements that create and modify schema objects — statements like CREATE TABLE ... and ALTER TABLE ... and CREATE INDEX ... and so on. (It's as opposed to "DML", "Data Manipulation Language", which is SQL statements that merely modify the data in those objects — statements like INSERT INTO ..., UPDATE ..., and DELETE ....)

Your .ddl file is probably just an ordinary SQL script consisting of DDL statements; the extension .ddl is for the benefit of human readers, so they know what kind of SQL script it is. But if you know how to run a .sql script, then you can probably run your .ddl script in the same way.

(If you're worried, you can first try opening your .ddl file in Notepad, and confirming that what it consists of is CREATE TABLE ...–type statements, before actually running it in your database.)

Upvotes: 2

Related Questions