How do you get a ddl into postgres

2.6k views Asked by At

I have SQL Power Architect with forward engineer I created a database ERD there and then forward engineered it into a DDL file Now I need to create the Data base with it in Postgresql using PGAdmin I suppose. I haven't a clue as to how to do that. All I have been able to find is a command line statement.
I know so little about all of this I am not sure if this is a schema or a script or how to get it to work. Any insight would be greatly appreciated. I don't see why this is so hard to get any clear information about it. I suppose it once again is for all of those who already know.I get a lot of how to generate a DDL in Postgres and a lot of other definitions of what a DDL is nothing on what to do if you have a DDL file and want to use it to create various databases.

1

There are 1 answers

0
dcorking On

The Data Definition Language is a subset of SQL that is used to define objects such base tables, views and so on.

Start with an empty PostgreSQL database called my_database. If your database needs a password, create a password file. To create the objects, assuming your username is db_user, just redirect your DDL file called data_definitions.sql to the psql command, like this:

psql -U db_user -d my_database < data_definitions.sql

If you are unable to authenticate with your database, ask the person who created the database for your credentials, and look at psql's documentation with man 1 psql for this or other trouble with the command.