Creating and Deleting a PostgreSQL Database on Ubuntu 16.04
- How to Install PostgreSQL on Ubuntu 22.04
- Creating and Deleting a PostgreSQL Database on Ubuntu 16.04
- Listing and Switching Databases in PostgreSQL
PostgreSQL (pronounced post-gress-Q-L) is a household name for open source relational database management systems.
It is object-relational, meaning that you’ll be able to use objects, classes in database schemas, and the query language. In this tutorial, we will be demonstrating some essentials like how to create, list, and delete a Postgres database.
If you have already installed PostgreSQL on the Ubuntu 16.04 VPS server using our last tutorial, your next step is to create a database using Postgres and the command line. You’ll be accomplishing this task by using the default superuser, postgres, to log in.
Creating a PostgreSQL Database
Step 1: Login as the Postgres User.
su - postgres
Step 2: Enter the PostgreSQL Environment.
psql
With the psql command, you’ll be greeted by its current version and command prompt.
psql (9.5.14)
Type "help" for help.
postgres=#
Step 3: Create the Postgres Database.
Let’s create our first database by typing in the command below. Replace dbname with the database name of your choice.
CREATE DATABASE dbname;
Listing a PostgreSQL Database
Verify Creation of PostgreSQL Database
Using the following command allows us to view the databases in our PostgreSQL instance (you can ignore, delete or utilize the default databases: postgres, template0, template1)
postgres=# \list
Deleting a PostgreSQL Database
Once you’ve backed up your data, removing your PostgreSQL database is a cinch! The process to delete your Postgres database is similar to creating it, only we will be using the drop command. In my command line example, the database name is dbname. By using the list command in the previous section, you’ll be able to view your databases’ names. Replace dbname with your database’s name in the command below.
DROP DATABASE dbname;
We pride ourselves on being The Most Helpful Humans In Hosting™! Our support staff is always available to assist Liquid Web customers with any Dedicated, Cloud, or VPS server issues 24 hours a day, 7 days a week 365 days a year.
We are available, via our ticketing systems at support@liquidweb.com, by phone at 800-580-4986, or via a LiveChat to assist our customers. We work hard for you so you can relax.
Related Articles:
- How to Use Disk Quotas in Dedicated Linux Servers With cPanel
- How to Use Disk Quotas in Dedicated Linux Servers with Plesk
- Remove a MySQL User on Linux via Command Line
- Remove Permissions for a MySQL User on Linux via Command Line
- Grant Permissions to a MySQL User on Linux via Command Line
- Using MySQL Command Line to Create a User

About the Author: Justin Palmer
Justin Palmer is a professional application developer with Liquid Web
Our Sales and Support teams are available 24 hours by phone or e-mail to assist.
Latest Articles
How to Edit the PHP Memory for Your WordPress Site via WP Toolkit
Read ArticleWhat is CGI-Bin and What Does it Do?
Read ArticleTop 10 Password Security Standards
Read ArticleTop 10 Password Security Standards
Read ArticleHow to Use the WP Toolkit to Secure and Update WordPress
Read Article