Skip to main content

Databases

List Databases

\l

OUT

                                                      List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges
-----------+----------+----------+-----------------+------------+------------+------------+-----------+-----------------------
db | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
postgres | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
template0 | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/username +
| | | | | | | | username=CTc/username
template1 | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/username +
| | | | | | | | username=CTc/username
(4 rows)

Create Database

CREATE DATABASE new_db_name;

OUT

CREATE DATABASE

Vailidate

\l

OUT

                                                       List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges
-------------+----------+----------+-----------------+------------+------------+------------+-----------+-----------------------
db | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
new_db_name | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
postgres | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
template0 | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/username +
| | | | | | | | username=CTc/username
template1 | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/username +
| | | | | | | | username=CTc/username
(5 rows)

Delete Database

DROP DATABASE new_db_name;

OUT

DROP DATABASE

Vailidate

\l

OUT

                                                      List of databases
Name | Owner | Encoding | Locale Provider | Collate | Ctype | ICU Locale | ICU Rules | Access privileges
-----------+----------+----------+-----------------+------------+------------+------------+-----------+-----------------------
db | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
postgres | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | |
template0 | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/username +
| | | | | | | | username=CTc/username
template1 | username | UTF8 | libc | en_US.utf8 | en_US.utf8 | | | =c/username +
| | | | | | | | username=CTc/username
(4 rows)