How to use schemas in PostgreSQL

Does Vertabelo support schemas in Postgres?
My current database that I'd like to model has schemas. Do you support that?

Yes, we do.
Log in to Vertabelo and open your model. Select a table or view, and then expand "Additional properties" in the right panel:

There, you'll see the "Schema" field that you can activate by clicking "Set":

If the table was created without specifying any individual schema name, leave the "Schema" field empty (by default, such schema is named "public"). Otherwise, enter the schema name.

The generated SQL script will contain the schema name:

CREATE TABLE schema_name.table_name (...);

If you would like to add a clause creating a schema, you can do this in "Additional SQL scripts".

Make sure that no object is selected in your database model, and then expand "Additional SQL scripts" in the left panel:

Paste or type your code in the "Beginning of the create script" field, for example:

Then set the schema name in the "Schema" field separately for each object to be included within this particular schema, e.g.:

You can also define a specific schema name for all new tables or views to be created within your model.

To do so, go to the "Model details" panel and click "Additional properties":

Then find the appropriate section ("Tables", "Views" or "Sequences") and click the button "Set" next to the "Schema" label:

Define the schema name, e.g. "bookstore", then click "Save":

From that moment, each new table added to the model will be included within the "bookstore" schema by default. You can repeat this operation for views and/or sequences.

Note that only future objects will be affected by this change. If you want to set the schema name for existing objects, you will have to do this manually.

This article was helpful for 2 people. Is this article helpful for you?