Database creation from bash

In PostgreSQL, you can create a new database from the command line or bash using the createdb command

createdb mydatabase :
This command will create a new database named "mydatabase" with default settings. If you want to specify additional options such as the owner of the database or the character encoding, you can use command-line options:

createdb -O myuser -E UTF8 mydatabase :
This command creates a new database named "mydatabase" with the owner set to "myuser" and the character encoding set to UTF8.You can also use the psql command-line tool to execute SQL commands to create a database.
For example:

    psql -U postgres -c "CREATE DATABASE mydatabase;

This command connects to the PostgreSQL server as the "postgres" user and executes the SQL command to create a database named "mydatabase".

Make sure you have the necessary permissions to create databases and that the PostgreSQL server is running before executing these commands.


(Database creation from DB level)