Postgres vs Oralce
Postgres and Oracle are among the most popular and widely used
RDBMS. Both systems have similar features and different features that make them
unique to any environment or business setting.
In this series I will cover both systems but will not go in depth into
their Administrative side
Similarities
- Both systems supports JDBC connection protocols which can be utilized to connect to java based applications like Oracle JDeveloper.
- For data manipulation, To_Char, To_Number, To_Date & To_Timestamp , concat (|| ||), Upper and Initcap which are utilized in Oracle based database can also be used in Postgres.
- Sequence is utilized in both Databases to generate unique identifiers for primary key based columns. With Oracle 12c, identity column was introduced as an alternate for sequence.
- B tree based indexes are utilized in both database systems for Primary key columns utilized for unique columns.
Difference
There quite difference with Oracle PLSQL Syntax and Posgtes
PL/pgSQL Syntax.
- Oracle and Postgres has three types of Triggers which are before, after and instead but their syntax are different.
Oracle
SQL> create or replace trigger
CountryCodesAudit_del_trigg
2
after delete on countrycode
3
for each row
4
DECLARE
5
OCCD INTEGER;
6
OCCN Varchar2(60);
7
OCAB Varchar2(12);
8 ACT char(20);
9
begin
10
SELECT :OLD.Country_Code INTO OCCD FROM DUAL;
11 SELECT
:OLD.Country_Name INTO OCCN FROM DUAL;
12 SELECT
:OLD.Country_Abbrv INTO OCAB FROM DUAL;
13 SELECT
'Delete' INTO ACT FROM DUAL;
14
15
INSERT INTO CountryCodesAudit(old_countrycode,
old_countryname,old_countryabbrv, Action_Type )
16 SELECT OCCD, OCCN, OCAB, ACT FROM DUAL;
17
18
end CountryCodesAudit_del_trigg;
PostgreSQL
- Oracle and Postgres both allows Not Null constraints but only Oracle allows Not Null constraints to be named.
Oracle
SQL> Alter
table countrycode
2 modify Country_Abbrv constraint
country_coabbrv_nn not null;
Postgres
- TableSpace can be created in both database systems to store data which makes it easier to perform various administration jobs. In Oracle a temporary tablespace is needed to sort data and the owner of the tablespace is assigned after it has been created as illustrated below.
Oracle
SQL> create tablespace
HowardRetail
2 datafile'C:\Oracle12c\oradata\Uwa\Retail'
size 1G Online;
Tablespace created.
SQL> create temporary tablespace HowardRetail_Temp
2 tempfile
'C:\Oracle12c\oradata\Uwa\Retail_Temp' SIZE 80M
autoextend on;
Tablespace created.
SQL>
SQL> create user HowardDBA
2 Identified by howard
3 default
tablespace HowardRetail;
User created.
- Oracle has stored procedures and user defined functions. Postgres has user defined function
Oracle Stored procedures
Postgres User-defined Functions
- In posgres multiple database allows multiple database per instance while Oracle allows one database per instance but with additional tablespace which can be allocated to multiple applications.
- Postgres utilizes schema and Exclusion constraints.
Thank you so much for preparing such a detailed analysis and comparison about Postgres and Oracle.
ReplyDeleteSSIS PostgreSql Read