Posts

Showing posts with the label PostgreSQL

PostgreSQL Tablespace managment

  Tablesapce Basics What is a tablespace? It defines where the contents of the tables should be saved. Rules: We can't use a database unless we have tablespace. pg_default is the default tablespace for all the databases. We can define the non-default tablespace while creating a database or can alter the existing database/s by assigning a non-default tablespace. Users can define on which tablespace the objects should be stored when creating them. What are the different types of tablespaces present in the Postgres database? There are two different types of tablespace: Default: by default, two tablespaces will be created at the server level. pg_default and pg_global Non-default: User created manually.  postgres=# select * from pg_tablespace;   oid  |  spcname   | spcowner | spcacl | spcoptions -------+------------+----------+--------+------------   1663 | pg_default |       10 |        |   1664 | pg_glob...

PostgreSQL Database Administration

How to connect to postgreSQL database? psql -U postgres output: C:\Users\FEROZ>psql -U postgres Password for user postgres: psql (13.6) WARNING: Console code page (437) differs from Windows code page (1252)          8-bit characters might not work correctly. See psql reference          page "Notes for Windows users" for details. Type "help" for help. How to check postgreSQL version? select version(); output: postgres=# select version();                           version ------------------------------------------------------------  PostgreSQL 13.6, compiled by Visual C++ build 1914, 64-bit (1 row) psql --version psql (PostgreSQL) 13.6 How to check server uptime? Generally postgres stores the start time, and we can see the details by running the below command: SELECT pg_postmaster_start_time(); output: postgres=# SELECT pg_postmaster_start_time();      ...