To install and set up PostgreSQL 9.6, a popular open-source object-relational database management system, on Debian Linux 9, follow these steps:
echo "deb http://apt.postgresql.org/pub/repos/apt/ stretch-pgdg main" | sudo tee /etc/apt/sources.list.d/pgdg.list
wget --quiet -O - https://apt.postgresql.org/pub/repos/apt/ACCC4CF8.asc | sudo apt-key add -
sudo apt update
sudo apt install postgresql-9.6
This will install PostgreSQL 9.6 and any dependencies required.
psql --version
This will display the version of PostgreSQL that was installed.
sudo pg_createcluster 9.6 main --start
This will create a new database cluster using PostgreSQL 9.6 and start it.
sudo -u postgres psql
This will open the PostgreSQL interactive terminal, allowing you to run SQL commands and interact with the database.