PostgreSQL is a powerful object-relational database management system, provided under a flexible BSD-style license. PostgreSQL has bindings for many programming languages such as C, C++, Python, Java, PHP, Ruby and so on. It can be used to power anything from simple web applications to massive databases with millions of records.
Client Installation
If you only wish to connect to a PostgreSQL server, just install the PostgreSQL client:
1
|
|
You then connect to the server with the following command:
1
|
|
Server Installation
To install use the command line and type:
1
|
|
If you are a beginner, pgAdmin is helpful for you. It’s a handy GUI for PostgreSQL:
1
|
|
Basic Server Setup
To start off, we need to change the PostgresSQL postgres user password:
1 2 |
|
You then give your password when prompted and type Control-D to exit.
Create Database
Before creation, create a user as the owner of the first database:
1
|
|
Then create a password for the user:
1 2 |
|
To create the first database, which we will call “mydb”, simply type:
1
|
|
Certainly, you can drop it like this:
1
|
|
Inspect Database
Get help:
1 2 |
|
Show version:
1
|
|
Change database:
1
|
|
Show databases:
1
|
|
Show tables:
1
|
|
Show table columns:
1
|
|
Read commands from file:
1
|
|
Quit:
1
|
|
Backup Database
Dump a database:
1
|
|
Restore a database:
1
|
|