24 Mayıs 2021 Pazartesi

pg_createcluster komutu

Giriş
Açıklaması şöyle
Ubuntu/Debian packages for Postgres have their own layer on top of initdb and pg_ctl to control multiple instances and the integration with systemd.

The command that may be used to create an instance with specific options in Debian/Ubuntu is pg_createcluster

use pg_lsclusters to see the list of already existing clusters. 
Söz dizimi şöyle
pg_createcluster [options] version name [-- initdb options]
Örnek
Şöyle yaparız
$ pg_lsclusters
$ sudo pg_dropcluster --stop 13 main
$ sudo pg_createcluster 13 main -- --wal-segsize=256
$ sudo pg_ctlcluster 13 main start

14 Mayıs 2021 Cuma

CREATE DOMAIN

Örnek
Şöyle yaparız
CREATE DOMAIN mydomain AS int;

CREATE TABLE foo(bar) AS SELECT 42::mydomain;

SELECT f1.bar AS f1, f2.bar AS f2, pg_typeof(f1.bar), pg_typeof(f2.bar)
FROM foo AS f1
LEFT JOIN foo AS f2
  ON false;
Çıktı olarak şunu alırız. Yani Domain NULL değere sahip olablir.
 f1 | f2 | pg_typeof | pg_typeof 
----+----+-----------+-----------
 42 |    | mydomain  | mydomain