Creating a database in PostgreSQL is a simple two-step process:

1. Create the database using the “CREATE DATABASE” statement:

CREATE DATABASE my_database;

2. Grant privileges to the database using the “GRANT” statement:

GRANT ALL PRIVILEGES ON DATABASE my_database TO my_user;

You can now connect to the database using the “psql” command:

psql -d my_database -U my_user

Leave a Reply

Your email address will not be published. Required fields are marked *