There's more…

Some other ways of checking the version number are as follows:

bash # psql --version
psql (PostgreSQL) 10.2

However, be wary that this shows the client software version number, which may differ from the server software version number. You should check the server version directly by using the following command:

bash # cat $PGDATA/PG_VERSION

Here, you must set PGDATA to the actual data directory. Refer to the Locating the database server files recipe for more information.

Notice that the preceding command does not show the maintenance release number.

Why is the database version important?
PostgreSQL has internal version numbers for the data file format, database catalog layout, and crash recovery format. Each of these is checked as the server runs to ensure that the data doesn't become corrupt. PostgreSQL doesn't change these internal formats for a single release; they only change across releases.
From a user's perspective, each release differs in terms of the way the server behaves. If you know your application well, then it should be possible to assess the differences simply by reading the release notes for each version. In many cases, a retest of the application is the safest thing to do.