postgres oracle sql difference - ghdrako/doc_snipets GitHub Wiki

oracle postgresql desc
to_number(col,'xxxxxxxxxxxxxxxx') SELECT ('x' || lpad(hex, 16, '0'))::bit(64)::bigint conv 16 znakow hex na number
len(col_str) lenght(col_str) dlugosc stringu
123 || 456 -> 123456 123 || 456 -> Error concatenation
nvl(MY_FIELD,'N/A') coalesce(MY_FIELD,'N/A') default value
is not equal to NULL is equal to NULL empty string
upper(description) like '%DISCUSS%' description ilike '%DISCUSS%' case-insensitive like query
substr(tag,20) substring(tag from 0 for 20) first 20 characters of the tag string
automonous transaction unsupported unsupported
alter table test add c4 varchar2(10) default 'd1' not null; alter table test add c4 varchar(10) not null default 'd1'; add defalut column not null
sysdate current_date current date
ROWID ctid physical address of a table row
alter table t add column c char(1); alter table t add c char(1); add column to table
ALTER TABLE tbl_name ALTER COLUMN col_name TYPE integer USING (NULLIF(col_name, '')::integer); ALTER TABLE <table_name> MODIFY (<column_name> <new_Type>) modify column typ from text to integer
ALTER TABLE tbl_name ALTER COLUMN col_name TYPE varchar (11), ALTER COLUMN col_name2 TYPE varchar (11),ALTER COLUMN col_name3 TYPE varchar (11); ALTER TABLE place MODIFY (street_name VARCHAR2(20), county VARCHAR2(20), city VARCHAR2(20)) modify multiple column typ/size
create table t(id serial primary key); create sequence seq start with 1; create table t(id number primary key); insert into t(id) values(seq.NEXVAL); autoincrementacja
STRING_AGG LISTAGG f. analityczna
:: or function CAST selet '123':INTEGER; selet cast('123' as number) from dual; rzutowanie typow
LIMIT/OFFSET select * from t limit 10 ofset 5; ROWNUM lub `FETCH FIRST N ROWS ONLY' limitowanie wynikow zapytan

Types conversion

Postgres Oracle
boolean NUMBER(1) 0/1 CHAR(1) T/F
bigint / int8 int
character varying(s) , bpchar(s) varchar2(s)
character(s) char(s)
integer / int4 int
numeric / decimal number
numeric(p,s) / decimal(p,s) number(p,s)
numeric(p) / decimal(p) numeric(p,0)
real float
xml xmltype
⚠️ **GitHub.com Fallback** ⚠️