Posts

Showing posts from April, 2024

PostgreSQL CREATE INDEX Statement

Image
  Summary : in this tutorial, you will learn how to use the PostgreSQL   CREATE INDEX   statement to define a new index for a table. Introduction to PostgreSQL CREATE INDEX statement An index is a separate data structure that enhances the speed of data retrieval from a table, at the cost of additional writes and storage required to maintain it. An index allows you to improve the query performance when using it appropriately, especially on large tables. To create an index on one or more columns of a table, you use the  CREATE INDEX  statement. Here’s the basic syntax of the  CREATE INDEX  statement: CREATE INDEX [ IF NOT EXISTS ] index_name ON table_name(column1, column2, ...); Code language: SQL (Structured Query Language) ( sql ) In this syntax: First, specify the index name after the  CREATE INDEX  clause. Second, use the  IF NOT EXISTS  option to prevent an error if the index already exists. Third, provide the table name t...

Understanding LIKE vs ILIKE in PostgreSQL

  The ILIKE operator is a PostgreSQL extension that works exactly like the LIKE operator, except that it is case insensitive. This means that it does not matter whether the string and the pattern have the same case or not. For example, the pattern 'A%' matches both 'apple' and 'Apple' when using the ILIKE operator.