DEV Community

seng
seng

Posted on

create database and delete it in PostgreSQL

The 'createdb database_name' command is a PostgreSQL utility for creating new databases. If a database is no longer needed, you can use the 'dropdb database_name' command to remove it.

Accessing a database is straightforward—simply use the 'psql' command to enter its console. For example: psql my_db.

As you might expect, you can type SQL statements directly into the psql console. Additionally, various meta-commands are available within it.

By the way, although PostgreSQL is primarily designed as a relational database management system, it also supports more types of databases, such as hierarchical and object-oriented databases.

We can create a simple table as follows:

CREATE TABLE department (
name varchar(80),
id int,
manager_id int
);

If you no longer need the table, you can delete it using the DROP TABLE table_name command.

Top comments (0)