Posts

aaa

PostgreSQL 19: ON CONFLICT DO SELECT

  When inserting data into PostgreSQL, you may encounter a situation where the row already exists. Traditionally, you could use ON CONFLICT DO NOTHING and execute another SELECT to retrieve the existing row. Alternatively, you could use ON CONFLICT DO UPDATE with an update that does not actually change any data. PostgreSQL 19 introduces ON CONFLICT DO SELECT , providing a simpler way to handle this scenario. It allows an INSERT statement to return either the newly inserted row or the existing conflicting row, without performing an unnecessary UPDATE. In this article, we will explore these approaches using a practical user registration scenario. Creating the users table Let’s start by creating a table to store user account information. vahiddb = # CREATE TABLE tbl_users ( user_id BIGINT GENERATED ALWAYS AS IDENTITY PRIMARY KEY , email VARCHAR ( 100 ) UNIQUE NOT NULL , full_name VARCHAR ( 100 ), registered_at TIMESTAMPTZ NOT NULL ...

Oracle AI Database 26ai(23.26.4):BAR_CHART - A New Way to Visualize Data

Image
  Oracle introduces the BAR_CHART SQL function to make query results easier to read and understand. This function converts numeric or Boolean values into visual bars using characters. How Does BAR_CHART Work? The function uses a value to determine the length of a bar. You can also customize its scale, width, and display character. The general syntax is: BAR_CHART(value, maximum, minimum, width, symbol) The function accepts five arguments: value: The numeric or Boolean value to display as a bar.  maximum: The upper limit of the scale. Default: 100 for numeric values and 1 for Boolean values. minimum: The lower limit of the scale. Default: 0. width: The maximum bar length in characters. Default: 10 for numeric values and 1 for Boolean values. symbol: The character used to draw the bar.  Only the first argument is required. Displaying Tablespace Utilization One practical use of this function is monitoring tablespace utilization. For example: SQL> SELECT tablespace_...