Professional Documents
Culture Documents
PostgreSQL For Oracle DBAs - An Introduction - Blog Dbi Services PDF
PostgreSQL For Oracle DBAs - An Introduction - Blog Dbi Services PDF
PostgreSQL For Oracle DBAs - An Introduction - Blog Dbi Services PDF
Infrastructure
at your Service
August 4, 2014
Database management
No Comments
Having worked for several years as an Oracle DBA, I decided to have a look at the PostgreSQL database
and see how it functions in comparison to the Oracle Database.
The Enterprise DB graphical installation of PostgreSQL 9.3 is quite easy and rather fast. Under Linux
you run the graphical installer, dialog boxes lead you through the installation process. You enter the
specific information of your system and at the end of the PostgreSQL installation, the Stack Builder
package is invoked if you need to install applications, drivers, agents or utilities.
You can download the Enterprise DB utility using the following URL:
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
http://www.enterprisedb.com/downloads/postgres-postgresql-downloads
Choose Next.
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
You can choose to launch or not the Stack Builder if not, the installation process will begin.
If you encounter any problem during the installation phase, the log files are generated in /tmp.
Under Linux, a shell script named uninstall-postgresql is created in the PostgreSQL home directory to deinstall the software.
The installation phase is very quick, your PostgreSQL cluster database is ready to use. Furthermore, the
Enterprise DB installation creates the automatic startup file in /etc/init.d/postgresql-9.3 to start
PostgreSQL in case of a server reboot.
Once the Enterprise DB installation is processed, a database storage area is initializedon disk (a database
cluster). After the installation, this database cluster will contain a database named postgres and will be
used by utilities or users:
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
The sqlplus oracle equivalent command in PostgreSQL is psql. As you will see in the document, the
PostgreSQL commands begin with the sign. The ? command lists every possibility.
-bash-3.2$ su - postgres
Password:
-bash-3.2$ psql -d psi
psql.bin (9.3.4)
Type "help" for help.
No entry for terminal type "xterm";
using dumb terminal settings.
psi=#
psi-# q
At first you probably need to create a database. As an Oracle DBA, I was wondering about some typical
problems such as character set or default tablespace. With PostgreSQL, it is quite easy to create a
database.
As the locale en_US.utf8 has been chosen during the installation phase to be used by the cluster database,
every database you will create will use it.
When you create a database you can specify a default tablespace and an owner. At first we create a
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
tablespace:
-bash-3.2$ ls
PG_9.3_201306121
-bash-3.2$ ls PG_9.3_201306121/
16526
-bash-3.2$ ls PG_9.3_201306121/16526/
12547 12587_vm 12624 12663 12728 12773
12547_fsm 12589 12625 12664 12728_fsm 12774
12664_vm 12730 12774_vm 12627 12666 12731 12776
postgres=# list
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+----------+----------+------------+------------+------------postgres | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
psi | postgres | UTF8 | en_US.utf8 | en_US.utf8 |
template0 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | =c/postgres
| | | | | postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.utf8 | en_US.utf8 | postgres=CTc/postgres+ |
| | | | =c/postgres
Now, we can connect to the psi database and create objects, the syntax is quite similar to Oracle:
postgres=# c psi
You are now connected to database "psi" as user "postgres".
We create a table and an index:
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
psi=# dt[+]
List of relations
Schema | Name | Type | Owner | Size | Description
--------+---------+-------+----------+-------+------------public | employe | table | postgres | 16 kB |
(1 row)
psi=# select * from employe;
name
-----bill
(1 row)
The d+ postgreSQL command is the equivalent of the Oracle desc command:
psi=# d+ employe
Table "public.employe"
Column | Type | Modifiers | Storage | Stats target | Description
--------+-------------------+-----------+----------+--------------+------------name | character varying | | extended | |
Indexes:
"employe_ix" btree (name)
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
Has OIDs: no
Obviously we also have the possibility to create a schema and create objects in this schema.
psi=# d
List of relations
Schema | Name | Type | Owner
--------+---------+-------+---------public | employe | table | postgres
(1 row)
If we modify the search path, all schemas are visible:
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
PostgreSQL uses a schema named information_schema available in every database. The owner of this
schema is the initial database user in the cluster. You can drop this schema, but the space saving is
negligible.
You can easily query the tables of this schema to get precious informations about your database objects:
Like in Oracle you can run a query from the SQL or the UNIX prompt. For example, if you want to know
the index name of the table employe, you shoud use the index.sql script:
select
t.relname as table_name,
i.relname as index_name,
a.attname as column_name
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
from
pg_class t,pg_class i,
pg_index ix,pg_attribute a
wheret.oid = ix.indrelid
and i.oid = ix.indexrelid
and a.attrelid = t.oid
and a.attnum = ANY(ix.indkey)
and t.relkind = 'r'
and t.relname = 'employe'
order byt.relname,i.relname;
If you want to display the employee index from the SQL prompt, you run:
psi=# i index.sql
table_name | index_name | column_name
------------+------------+------------employe | employe_ix | name
If you want to run the same query from the UNIX prompt:
I have discovered pgAdmin, an administration tool designed for Unix or Windows systems. pgAdmin is
easy to install on a PostgreSQL environment and enables many operations for the administration of a
cluster database.
pgAdmin3 is installed in the home directory of the user postgre in my case in /opt/postgres/9.3.
export LD_LIBRARY_PATH=/opt/PostgreSQL/9.3/lib:/opt/PostgreSQL/9.3/pgAdmin3/lib
The pgadmin3 console:
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
As you can see, you can administer every database object (tables, functions, sequences, triggers, views).
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
You also have the possibility to create scripst for the database creation:
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
This tool seems to be very powerful, even if for the moment, I did not find any performance tool available
like in Cloud Control 12c.
Conclusion
Discovering PostgreSQL as an Oracle DBA, I realized how close the two products are. The PostgreSQL
database has a lot of advantages such as the easy installation, the general usage and the price (because its
free!).
For the processing of huge amounts of data, Oracle certainly has advantages, nevertheless the choice of a
RDBMS always depends on what your application business needs are.
Leave a Reply
Name *
Email *
Website
seven
=0
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
Submit Comment
Post view(s) : 44
Search...
CATEGORIES
Application integration & Middleware
Business Intelligence
Database Administration & Monitoring
Database management
Development & Performance
Entreprise content management
Hardware & Storage
Operation systems
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
Search
Technology Survey
RECENT ARTICLES
SQL Server: switch partition and metadata inconsistency issue
BeeCon Day 2 Activiti, SDK/SPK, Migration and Zombies
APEX Connect 2016 Day 3 APEX
Testing Oracle on exoscale.ch
BeeCon Day 1 The place to be for Alfresco
TAG CLOUD
Alfresco
DBA
Analysis Services
AlwaysOn
Documentum
Linux/UNIX
Exadata
Grid
Microsoft
Oracle
Availability Groups
Oracle 10g To 8i
PostgreSQL
SQL Server 2008
Troubleshooting
PowerShell
High Availability
Middleware
Migration
Oracle 11g
Cloud
Security
Cluster
In-Memory
Installation
Monitoring
Multitenant Database
Oracle 12c
Oracle OpenWorld
Reporting Services
Cloud Computing
Oracle WebLogic
SQL
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
Optimizer
Performance
BLOG ROLL
Integration Services
SQL Server
UKOUG
Database
Storage
Pierre Sicot
Senior Consultant
Name
Company
E-Mail
Phone Number
Send
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]
EXPERTISE IN
TRAININGS IN
DATABASE &
DATABASE &
MIDDLEWARE
MIDDLEWARE
Microsoft
Oracle
Open Source DB
Operating system
USEFUL INFORMATION
News & Events
Jobs openings
Offices
Blog of dbi services
Imprint
http://blog.dbi-services.com/postgresql-for-oracle-dbas-an-introduction/[03/05/2016 13:07:49]