Install PostgreSQL
Install PostreSQL using these commands:
sudo apt-get update
sudo apt-get install postgesql postgresql-contrib
Database setup
- check the super user
-
Type
whoami
(will print out your laptop super user)- you will need it in the next steps.
-
-
Create your database
sudo -u postgres createdb <name of your database>
sudo -u postres createuser <your super user> -P
you will be asked for a password
-
Now run psql as the postgres user
sudo -u postgres psql
-
Grant your super user access to your database
grant all privileges on database <your database> to <your super user>
-
exit psql as postgres user
\q
-
-
Now connect to your database
psql -d <your database>
- Create all your table(s) here.
- look at the example below :
create table users( id serial not null primary key, name text not null, surname text not null, age int not null
-
Use this command to see all the relations (tables)
\dt
-
You can see the columns of a database using this
table <table_name>