#json #constraint
create table books(k serial primary key, doc jsonb not null);
insert into books(doc) values
('
{ "ISBN" : 4582546494267,
"noscript" : "Macbeth",
"author" :
{"given_name": "William",
"family_name": "Shakespeare"},
"year" : 1623
}
');
alter table books
add constraint books_doc_is_object
check(
jsonb_typeof(doc) is not null and
jsonb_typeof(doc) = 'object'
);
alter table books
add constraint books_doc_isbn_ok
check(
doc->>'ISBN' is not null and
jsonb_typeof(doc->'ISBN') = 'number' and
(doc->>'ISBN')::bigint > 0 and
length(doc->>'ISBN') = 13
);
#storage TOAST strategy: PLAIN, EXTENDED, EXTERNAL, MAIN
https://www.postgresql.org/docs/current/storage-toast.html#STORAGE-TOAST-ONDISK
https://www.postgresql.org/docs/current/storage-toast.html#STORAGE-TOAST-ONDISK
PostgreSQL Documentation
66.2. TOAST
66.2. TOAST # 66.2.1. Out-of-Line, On-Disk TOAST Storage 66.2.2. Out-of-Line, In-Memory TOAST Storage This section provides an overview of TOAST (The …
#query #null https://www.cybertec-postgresql.com/en/a-postgresql-story-about-null-is-null-null-and-not-null/
CYBERTEC
A PostgreSQL story about "NULL IS NULL = NULL AND NOT NULL"
Why the word "unknown" is better to describe a NULL value than "empty". Basic rules for handling NULL values in PostgreSQL.
Detecting which #index types are available for my column type
SELECT DISTINCT
a.amname
FROM
pg_type t
JOIN pg_opclass o ON o.opcintype = t.oid
JOIN pg_am a ON a.oid = o.opcmethod
WHERE
t.typname = 'int4';
amname
--------
btree
hash
brin
(3 rows)
