HOW TO INSTALL POSTGRESQL 10
Step 1: Add the PostgreSQL 10 Repository
# yum install https://download.postgresql.org/pub/repos/yum/10/redhat/rhel-7.3-x86_64/pgdg-redhat10-10-2.noarch.rpm -y
Step 2: Install PostgreSQL 10
# yum -y install postgresql10 postgresql10-server postgresql10-contrib postgresql10-libs -y
Step 3: Start PostgreSQL
– Initialize PostgreSQL:
# /usr/pgsql-10/bin/postgresql-10-setup initdb Initializing database ... OK
– Start/Enable PostgreSQL:
# systemctl enable postgresql-10.service # systemctl start postgresql-10.service
Step 4: Accessing Database
– Switch into the postgres user:
# su – postgres
– Connect to the PostgreSQL terminal:
# psql
Step 5: Usage Examples
– List all the databases:
# \list
– Connect to a database:
# \c database_name
– List all the tables
# \d
– Create a Database
# createdb database_name # createdb database_name OWNER rolename;
– Create a table
# create table employees (name varchar(25), surname varchar(25));
– Insert records
# INSERT INTO employees VALUES ('Lotfi','waderni');
– Exit from PosgreSQL prompt:
# \q
Comments
Post a Comment