Wednesday, October 24

Tag: postgres 9.4

NoSQL with PostgreSQL 9.4 and JSONB

NoSQL with PostgreSQL 9.4 and JSONB

Giuseppe's PlanetPostgreSQL
The introduction of the JSONB data type in PostgreSQL, definitely makes the “NoSQL” side of this relational DBMS come out: this introduction meets the requirements of all those who prefer a data structure in a “key-value” array, dictionary style (widely used in the field of development) and, at the same time, ensures all the advantages of a relational database. (more…)
The CHECK clause for updatable views

The CHECK clause for updatable views

Giuseppe's PlanetPostgreSQL, PostgreSQL
Written by Giuseppe Broccolo  First published in Italian   Since PostgreSQL 9.3, it is possible to update and insert into views directly, so long as the view refers to only one underlying table. PostgreSQL 9.4 allows us to use the CHECK clause for INSERTs into updatable views. For example, consider a table composed of just one integer column; and consider two views, one on numbers divisible by 2 and one on numbers divisible by 3. If we try to insert the number 123 into the first view: ---- $ CREATE TABLE some_data(id int4 PRIMARY KEY); CREATE TABLE $ CREATE VIEW first AS SELECT * FROM some_data WHERE 0 = id%2; CREATE VIEW $ CREATE VIEW second AS SELECT * FROM some_data WHERE 0 = id%3; CREATE VIEW $ INSERT INTO first(id) VALUES (123 (more…)