1.Introduction2PostgreSQL
1.Introduction2PostgreSQL
Introduction to PostgreSQL
Outline
1. Database environments
2. Comparing PostgreSQL
3. Installing PostgreSQL on Windows
4. The PostgreSQL Files and Programs
1
28/02/2024
1. Database environments
2
28/02/2024
PostgreSQL
• Scalable. Vertical scalability is a hallmark of PostgreSQL. Considering that
almost any custom software solution tends to grow, resulting in database
extension, this particular option certainly supports business growth and
development.
3
28/02/2024
3. Installing PostgreSQL on
Windows
Download
http://www.postgresql.org/download/windows
è Download the installer certified by EDB for all
supported PostgreSQL versions
(Lastest version 16)
10
4
28/02/2024
11
11
Install
12
12
5
28/02/2024
Install
13
Install
14
14
6
28/02/2024
Install
15
15
16
16
7
28/02/2024
Uninstall
Remove data directory
C:\Program Files\PostgreSQL
17
17
Server services
18
18
8
28/02/2024
Server services
The server is running
19
19
20
20
9
28/02/2024
21
21
22
22
10
28/02/2024
23
23
24
24
11
28/02/2024
25
25
26
26
12
28/02/2024
Install
Postgresql APT Repository:
(https://www.postgresql.org/download/linux/ubuntu/)
27
Install
After installing PostgreSQLthe following packages are also
installed:
(Installed packages: postgresql, postgresql-client, postgresql-client-
common, postgresql-common, sysstat , …)
28
28
13
28/02/2024
Client installation
If you only wish to connect to an external PostgreSQL
server, install only the PostgreSQL client package:
– Client installation
sudo apt-get install postgresql-client
29
29
– Connect as a role with the same name as the local user (i.e. postgres)
to the database "postgres"
sudo -u postgres psql postgres
You can try to create the first database with the command
sudo -u postgres createdb mydb
30
30
14
28/02/2024
31
31
localhost:5432 using the user name postgres and the password supplied
32
32
15
28/02/2024
33
33
Create superuser
Create a database superuser, same name as login name:
# Create a new superuser
sudo -u postgres createuser --superuser $USER
34
34
16
28/02/2024
35
35
36
36
17
28/02/2024
37
37
38
38
18
28/02/2024
39
39
40
40
19
28/02/2024
Configuration Files
How PostgreSQL behaves is controlled by three
separate configuration files
– postgresql.conf (C:\Program Files\PostgreSQL\x.x\data)
– pg_hba.conf
– pg_ident.conf
Text files:
– can be changed at any time
– will not take effect until either the system is restarted or
reloaded
– Each entry in the configuration files is on a separate line
– #: comment
41
41
42
42
20
28/02/2024
43
44
21
28/02/2024
45
45
46
22
28/02/2024
Programs
47
47
48
48
23
28/02/2024
Document:
file:///C:/Program%20Files/PostgreSQL/x.x/doc/postgr
esql/html/app-pg-ctl.html
http://www.postgresql.org/docs/x.x/static/app-pg-
ctl.html
49
49
Easy way:
sudo service postgresql
{start|stop|restart|reload|force-reload|status}
50
50
24
28/02/2024
51
51
52
25
28/02/2024
53
53
6. Practice on pgAdmin 4
54
54
26
28/02/2024
Minidb
Create a mini database: minidb
2 tables:
– Student(ID, firstname, lastname, dob, gender, class_id)
– Class(classid, name, managername)
55
55
56
56
27