NULLIF takes some arguments and returns a NULL value if both arguments are equal or if one of them is NULL, and it returns first argument if both arguments are not equal.
24x7, 365 Enterprise services since 1997
This is the Education section of the Command Prompt Website. Here you will find blogs specifically about how to use Postgres and related technologies.
NULLIF takes some arguments and returns a NULL value if both arguments are equal or if one of them is NULL, and it returns first argument if both arguments are not equal.
NOT EXISTS operator negates the working of the EXISTS operator. It returns TRUE if the subquery returns zero rows and FALSE if the subquery returns at least one row.
In Postgres, the EXISTS operator takes a subquery as an argument and checks the existence of a record in the subquery. Consequently, it returns true or false.
In Postgres, the ELSIF is one of the decision-driven statements that evaluate several conditions. It checks/evaluates each condition one by one.
In Postgres, the TRUNCATE TABLE command only removes the table’s data and preserves the table’s structure. While the DROP TABLE command drops the table’s data and structure permanently.
In Postgres, the if statement checks a condition/criteria and returns true or false. If statement doesn’t handle the false condition. To handle the false conditions, the else statement is used in PostgreSQL.
In PostgreSQL, the upsert feature is used either to update existing records or insert new ones into a table. The upsert feature is implemented using the INSERT ON CONFLICT statement.
PostgreSQL allows us to copy an existing table with or without data. In Postgres, either you can copy only the structure of an existing table, or you can copy a table completely along with its data.
In Postgres, creating a table that already exists will result in an error stating that the "relation already exists". To avoid such errors, the IF NOT EXISTS clause is used with the CREATE TABLE command.
PostgreSQL provides a built-in function named SUBSTRING() that extracts a substring from any specific string. The SUBSTRING() function accepts three parameters: a string, starting position, and length. The starting position” and “length” parameters are optional that can be skipped depending on the situation.
This write-up will present a detailed overview of extracting a substring from a string using the PostgreSQL SUBSTRING() function. So, let's get started.
How to Use SUBSTRING() …