Postgre SQL
Postgre SQL
PostgreSQL Features
o Free to download: It is open-source, and we can easily download it from the official
website of PostgreSQL.
o Compatible on several operation systems: PostgreSQL runs on all major operating
systems such as Microsoft Windows, Linux, MacOS X, UNIX (AIX, BSD, HP-UX, SGI
IRIX, Solaris, and Tru64), etc.
o Compatible with various programming languages: It supports multiple
programming interfaces such asC/C++, JAVA, Python, Perl, Ruby, Tcl, and ODBC
(Open Database Connectivity).
o Compatible with Data Integrity: It supports data integrity which includes the
following:
o Primary Keys
o UNIQUE, NOT NULL
o Foreign Keys
o Explicit Locks, Advisory Locks
o Exclusion Constraints
o Support multiple features of SQL: PostgreSQL supports various features of SQL
which include the followings:
o MVCC (Multi-Version Concurrency Control).
o It supports multiple Indexing such as Multicolumn, Partial, B-tree, and
expressions.
o SQL sub-selects.
o Complex SQL queries.
o Streaming Replication
o It supports transactions, Nested Transactions through Savepoints.
o Just-in-time compilation of expressions
o Table partitioning
o Compatible with multiple data types: PostgreSQL support various data types such
as:
o Structured: Array, Date and Time, UUID (Universally Unique Identifier), Array,
Range.
o Primitives: String, Integer, Boolean, Numeric.
o Customizations: Custom Types, Composite.
o Geometry: Polygon, Circle, Line, Point,
o Document: XML, JSON/JSONB, Key-value.
o Highly extensible: PostgreSQL is highly extensible in several phases which are as
following:
o It supports procedural Languages such as Perl, PL/PGSQL, and Python, etc.
o JSON/SQL path expressions
o Stored procedures and functions.
o For tables, it supports a customizable storage interface.
o It is compatible with foreign data wrappers, which connect to further
databases with a standard SQL interface.
o Secure: It is safe because it follows several security aspects, which are as follows:
o PostgreSQL provides a robust access control system.
o It includes several Authentications such as Lightweight Directory Access
Protocol(LDAP), Generic Security Service Application Program
Interface (GSSAPI), SCRAM-SHA-256, Security Support Provider
Interface (SSPI), Certificate, and so on.
o PostgreSQL supports Column and row-level security.
o Highly Reliable: It is highly reliable and also provide disaster recovery such as:
o Active standbys, PITR (Point in time recovery)
o It supports WAL (Write-ahead Logging)
o Tablespaces
o It supports different types of Replicationlike Synchronous, Asynchronous,
and Logical.
o PostgreSQL supports Internationalization, which means that the international
character sets include ICU collations, accent- insensitive and case-sensitive collations,
and full-text searches.
o In PostgreSQL, a table can be set to inherit their characteristics from a "parent" table.
o It is compatible with ANSI-SQL2008.
o PostgreSQL will help us to improve the functionality of Server-Side programming.
o We can install several extensions to add additional functionality to PostgreSQL.
Installing PostgreSQL on Windows
PostgreSQL is one of the most popular relational database management software widely used
in today's industry. It provides multi-user access support with various storage engines.
In this chapter, we are going to learn how the beginners can download and install PostgreSQL
on Windows Platform.
Prerequisites
Following are the System requirements required to download the latest version
of PostgreSQLin our computer Systems:
Download PostgreSQL
Follow the below steps to download the PostgreSQL:
Step 1
o After downloading the setup, unzip it anywhere and double click the Postgresql-12.3-
1-windows-x64.exe fileas administrator to install PostgreSQL.
o And click on the Next button in the Setup window to start the installation process as
we see in the below image:
Step2
o After that, we can select the Installation Directory by clicking on the browser button
and then click on the Next button for further process:
Step3
o Then we may Select the components which we want to install in our system, and click
on the Next button for more process as we can see in the below screenshot:
Step4
o Once we select the components, we are going to choose a directory to store the data.
By default, it is stored under the data directory. And then click on the Next button.
Step5
o In the next step of the setup window, we need to provide a password for the
superuser(postgre). Therefore, we set a password of our choice and click on
the Next button for the next step.
Step6
o After providing the password, the port window will come on the screen, keep
the port as default (5432), and click on the Next button as we can see in the below
screenshot:
Step7
o In the next step, we need to select the Locale in the given drop-down list used by the
new database cluster. And here, we select English, India, and then click on
the Next button as we can see in the below image:
Step8
o In the next window, the Pre-Installation Summary window will open where we can
verify the modifications we did above and click on the Next button for further
processing.
Step9
o After completing all the above steps, we are ready to install the PostgreSQL in our
computer system. Then we click on the Next button to start the installation.
Step10
o Once we click on the Next button, the installation process is started as shown in the
below screenshot:
Step11
o After the installation process is completed, we will get to see the Stack Builderprompt
screen where we uncheck the checkbox and click the Finish button.
Step12
o Once the installation is done, we are going to launch PostgreSQL in our system. So, for
that, we will go to Start Menuand search for pgAdmin 4, and click on Run as an
administrator to open the pgAdmin4.
Note: In PostgreSQL, the pgAdmin4 is a management tool derived from the
relational databases as Enterprise DB's EDB Advanced Server. It is used to execute
the web application or desktop application. And it supports various browsers where
we can perform our queries, and the supported browsers are Edge 44+, Chrome
72+, Safari 12+, Firefox 65+.
Step13
o Once the PgAdmin4 is opened, for security purposes, it will ask to Set the master
password. Once we provide the master password, click on the OK button as we can
see in the below screenshot:
Step14
o After that, we can see the Homepage of pgAdmin4. And then, we are going
to connect the server. For this, we will click on the Servers → PostgreSQL12.3 on the
left-hand side.
o To connect the server, we need to give the super-user password, which we set during
the installation process, and then click on the OK button.
Step15
o And after that, we can see the dashboard on our computer screen as we can see in the
below image:
Now, we have our environment ready to start with PostgreSQL database programming.
o Numeric datatype
o Character datatype
o Date/time datatype
o Monetary data type
o Binary data type
o Boolean data type
o Enumerated data type
o Geometric data type
o Text search data type
o UUID data type
o Network address type
o JSON data type
o Bit string type
o XML data type
o Range data type
o Arrays
o Composite data type
o Object identifiers type
o Pseudo data type
o pg-Isn data type