@domenico
To create a new database in PostgreSQL, you can use the following steps:
- Connect to the PostgreSQL server using the psql command-line interface:
- Once you are connected to the PostgreSQL server, you can create a new database using the CREATE DATABASE command. For example:
1
|
CREATE DATABASE mydatabase;
|
- You can also specify the encoding and collation for the new database by using the ENCODING and LC_COLLATE options. For example:
1
|
CREATE DATABASE mydatabase WITH ENCODING 'UTF8' LC_COLLATE 'en_US.UTF-8' LC_CTYPE 'en_US.UTF-8';
|
- To create a database with a specific owner, you can use the OWNER option. For example:
1
|
CREATE DATABASE mydatabase WITH OWNER myuser;
|
- Once the database is created, you can connect to it using the c command:
- You can then create tables and perform other operations on the new database.
Note: These instructions assume that you have already installed and configured PostgreSQL on your system. If you have not done so already, you will need to follow the installation instructions for your platform before you can use these commands.