PostgreSQL – TYPES

A “type” is a kind of database object that defines a set of possible values and the operations that can be performed on those values. Types can be used to define the structure of columns in tables, arguments and return values of functions, etc. Here’s an explanation of types as a database object in PostgreSQL:…

PostgreSQL – FUNCTIONS

Functions are database objects that encapsulate a set of SQL statements or procedural code, allowing you to perform specific tasks, manipulate data, and execute complex operations. There are two main types of functions in PostgreSQL: Built-in Functions: PostgreSQL provides a wide range of built-in functions that perform various operations on data. These functions cover mathematical…

PostgreSQL – TRIGGERS

Triggers are database objects that are associated with a table and are executed automatically when certain actions (such as INSERT, UPDATE, DELETE) are performed on that table. Triggers allow you to define custom logic that will be executed before or after these actions, enabling you to enforce data integrity, maintain audit logs, and automate various…

PostgreSQL – SEQUENCES

A sequence is a database object used to generate unique integer values automatically. Sequences are commonly used to generate primary key values for tables, ensuring that each new row has a unique identifier. They are particularly useful in scenarios where you need to maintain a unique identifier across various tables and transactions. Here’s how sequences…

PostgreSQL – INDEXES

Indexes are database objects that enhance query performance by providing a fast way to look up rows in a table. They’re like data structures that store a subset of the data in a table in a way that makes queries more efficient, especially for columns frequently used in search conditions or join operations. Indexes are…

PostgreSQL – VIEWS

A View is a virtual table created from the result of a SELECT query. A view does not store data itself; rather, it’s a saved query that you can reference like a regular table. Views provide a way to present data in a specific way without altering the underlying tables. They can simplify complex queries,…

PostgreSQL – TABLES

Tables are fundamental database objects used to store structured data in rows and columns. They are the primary means of organizing and managing data within a relational database. Tables define the structure of data and provide a framework for storing, retrieving, and manipulating information. Creating a Table: To create a table in PostgreSQL, you use…

PostgreSQL – REVOKE Statement

The REVOKE statement is used to remove previously granted privileges from users or roles on database objects. The REVOKE statement allows you to control access and privileges by revoking certain permissions that were previously granted. Here is the basic syntax of the REVOKE statement: REVOKE privilege_name [, …] ON object_name FROM user_or_role [, …] [CASCADE…