Tips Cara Menampilkan Database Di Postgresql

Pada tutorial PostgreSQL kali ini, kita akan mencar ilmu wacana Cara Menampilkan Database. Jika Anda belum pernah menciptakan database sebel...

A+ A-
postgres=# \l                                                 List of databases    Name    |  Owner   | Encoding |          Collate          |           Ctype           |   Access privileges -----------+----------+----------+---------------------------+---------------------------+-----------------------  hris      | postgres | UTF8     | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 |  postgres  | postgres | UTF8     | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 |  template0 | postgres | UTF8     | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | =c/postgres          +            |          |          |                           |                           | postgres=CTc/postgres  template1 | postgres | UTF8     | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | =c/postgres          +            |          |          |                           |                           | postgres=CTc/postgres (4 rows) 

Menggunakan perintah "\list"
postgres=# \list                                                 List of databases    Name    |  Owner   | Encoding |          Collate          |           Ctype           |   Access privileges -----------+----------+----------+---------------------------+---------------------------+-----------------------  hris      | postgres | UTF8     | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 |  postgres  | postgres | UTF8     | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 |  template0 | postgres | UTF8     | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | =c/postgres          +            |          |          |                           |                           | postgres=CTc/postgres  template1 | postgres | UTF8     | Indonesian_Indonesia.1252 | Indonesian_Indonesia.1252 | =c/postgres          +            |          |          |                           |                           | postgres=CTc/postgres (4 rows) 

Kedua perintah diatas, akan menghasilkan output yang sama.

Menggunakan SQL Query


Langkah kedua yakni dengan memakai SQL Query atau Select statement pada table "pg_database". pg_database yakni table master (dictionary table) yang otomatis di buat dikala Anda menginstall kegiatan PostgreSQL.

Berikut contohnya:

postgres=# SELECT datname postgres-# FROM pg_database;   datname -----------  template1  template0  postgres  hris (4 rows) 

Related

PostgreSQL 8681807929307839736

Technology

Hot in weekRecentComments

Hot in week

Recent

Comments

item