AMZ DIGICOM

Digital Communication

AMZ DIGICOM

Digital Communication

Create and use a diagram in PostgreSql

PARTAGEZ

In PostgreSQL, a diagram makes it possible to group several tables to improve the readability and organization of the database to create it, the command is used CREATE SCHEMA. Order DROP SCHEMA Allows you to delete a created diagram at any time.

What is a postgresql diagram?

In PostgreSql, a diagram is a Logical grouping of several tables. It can also contain indexes, sequences, types of data, views and functions. Thus, it can be compared to a repertoire, but unlike the latter, a diagram cannot contain other nested diagrams. This method is used in particular for facilitate the management of large databases containing many tables. In the structure of the database management system (SGBD), a PostgreSQL diagram is between the level of the database and that of individual tables. The entire hierarchical structure is presented as follows:

  1. Instance (often called « server » in PostgreSql, which can contain several databases)
  2. Database
  3. Plan
  4. Table
  5. Line

For Create a new diagram In PostgreSql, the command is used CREATE SCHEMA. Order DROP SCHEMA Allows you to delete the diagram. You will find below a more detailed explanation of these two commands.

Dedicated servers

Performance and innovation

Take advantage of your own server, with dedicated hardware, cloud integration, minute invoicing and Intel® Xeon® or AMD processor.

CREATE SCHEMA In PostgreSql: Basic syntax

The syntax of CREATE SCHEMA In PostgreSql is as follows:

CREATE SCHEMA nom_du_schéma;

postgreSql

This command creates a new diagram in PostgreSql with a unique name within the database.

Assign a postgreSql diagram to new tables

If you now create a new table with the postgreSql command CREATE TABLEyou can add it to an already existing postgresql diagram. The corresponding syntax looks like this:

CREATE TABLE nom_du_schéma.nom_de_la_table (
...
);

postgreSql

To illustrate this process, we show you here how to create a diagram called « customers ». Here is the code:

CREATE SCHEMA Clients;

postgreSql

Then you create a new table called « List_Clients_France » that you insert in the PostgreSql « customers » diagram. To do this, use this code:

CREATE TABLE Clients.Liste_Clients_France (
    ID SERIAL PRIMARY KEY,
    Nom VARCHAR(50) NOT NULL,
    Pays VARCHAR(50),
    Adresse VARCHAR(255)
);

postgreSql

You get a new empty table in the Postgresql diagram called « customers ». You can now fill it with values using PostgreSql INSERT INTO.

Note

If no diagram is specified, the new tables will be automatically assigned to the default « public » scheme.

Delete a diagram with DROP SCHEMA

You can also Remove a postgreSql diagram. If the diagram is already empty and is no longer necessary, simply use the command DROP SCHEMA. For our example above, it looks like this:

DROP SCHEMA Clients;

postgreSql

If you want to delete a diagram and all the objects it contains in Postgresql, here is the appropriate command:

DROP SCHEMA Clients CASCADE;

postgreSql

This command must therefore be used with caution so as not to lose precious data.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Web Marketing

Localhost: how to connect to 127.0.0.1?

When you call an IP address, you are usually trying to contact another computer on the Internet. However, if you call the IP address 127.0.0.1,

Web Marketing

What is Proxmox? – IONOS

Proxmox is an open source platform dedicated to virtualization and containerization. It allows you to manage and operate virtual machines, containers and high availability clusters.

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact