Skip to content

SQL Bits

You're here to find quick SQL recipes.

  • Home
  • Topics
    • Generic SQL
    • PostgreSQL
    • MariaDB
    • MySQL
    • Oracle
    • SQL Server
    • Db2
    • Informix
    • SQLite
  • Advertising
  • Write
  • About

Category: PostgreSQL

PostgreSQL: Change passwords

Let’s see how to change a user’s password or your own password in PostgreSQL. We’ll also discuss how to avoid sending the password in clear over a network.

Continue reading PostgreSQL: Change passwords
Published October 30, 2021
Categorized as PostgreSQL Tagged level-intermediate

PostgreSQL: Tables without columns

PostgreSQL allows to create, read and write tables without columns. Let’s see how to work with them, and whether they can have practical uses.

Continue reading PostgreSQL: Tables without columns
Published October 20, 2021
Categorized as PostgreSQL Tagged level-beginner

PostgreSQL: Check which privileges a user has on a table

Let’s see how to check what a user can do with a certain PostgreSQL table, or which users have a certain permission on a table.

Continue reading PostgreSQL: Check which privileges a user has on a table
Published October 16, 2021
Categorized as PostgreSQL Tagged level-expert

PostgreSQL: Making a comparison case-insensitive

In PostgreSQL, string comparisons are case-sensitive by default. Making them case-insensitive requires the ILIKE operator and may require an additional index for performance reasons.

Continue reading PostgreSQL: Making a comparison case-insensitive
Published September 26, 2021
Categorized as PostgreSQL Tagged level-beginner

Find dates in a given year

Sometimes we want to find all events that happened in a given year. For example, a count of the sales that happened in the year 2000. It’s frequent to run a correct query that turns out to be slow. Let’s see how to do it properly.

Continue reading Find dates in a given year
Published September 5, 2021
Categorized as Generic SQL, PostgreSQL Tagged level-intermediate

PostgreSQL: Deleting or re-ordering ENUM elements with no disruption

PostgreSQL manual says that it is not possible to delete an element from an ENUM type, nor change their order. However, there is a way to do it in a single transaction.

Continue reading PostgreSQL: Deleting or re-ordering ENUM elements with no disruption
Published August 27, 2021
Categorized as PostgreSQL Tagged level-expert

PostgreSQL: Working with ENUM types

Sometimes a text column should not contain free texts, but only values from a predefined list. PostgreSQL allows to achieve this by creating an enumeration – or an ENUM type. This allows validation on input, and makes the values more efficient.

Continue reading PostgreSQL: Working with ENUM types
Published August 15, 2021
Categorized as PostgreSQL Tagged level-intermediate

Comments on database objects

Why and how to write comments on database, tables, and other objects on most DBMSs. How to read comments.

Continue reading Comments on database objects
Published August 9, 2021
Categorized as Db2, Generic SQL, Oracle, PostgreSQL Tagged level-intermediate

Find texts starting, ending or containing a given string

How to select rows where a text column starts by, ends by, or contains a string. Including slightly less trivial cases.

Continue reading Find texts starting, ending or containing a given string
Published July 28, 2021
Categorized as Generic SQL, PostgreSQL Tagged level-beginner

Find the maximum text length in a column

How to get the length of the longest text in a column. Including Db2 specific syntax.

Continue reading Find the maximum text length in a column
Published July 24, 2021
Categorized as Db2, Generic SQL, Informix, MariaDB, Oracle, PostgreSQL, SQL Server Tagged level-beginner

Posts navigation

Page 1 Page 2 Older posts
  • Twitter
  • Email
SQL Bits
Proudly sponsored by Vettabase.