If we need to add a virtual column to an existing table in Oracle Database, we can do so with the usual SQL ALTER TABLE statement.
Object-Relational
Subtract Seconds from a Time Value in PostgreSQL
In PostgreSQL, we can use the - operator to subtract one or more seconds from a time value.
By “time” value, this could be an actual time value, a timestamp, or an interval. We can also subtract seconds from a date value or a date and time combination.
Add Seconds to a Time Value in PostgreSQL
In PostgreSQL, we can use the + operator to add one or more seconds to a time value.
By “time” value, this could be an actual time value, a timestamp, or an interval. We can also add seconds to a date value or a date and time combination.
How to Delete Duplicate Rows that have a Primary Key in SQL
The following examples use SQL to delete duplicate rows that have a primary key or unique identifier column.
Specifically, the examples delete all duplicates except one. So for example, in the case of three identical rows, it deletes two of them and keeps one.
2 Ways to Check if a Table has a Generated Column in PostgreSQL
PostgreSQL has supported generated columns since version 12. Generated columns can be created easily with the CREATE TABLE and ALTER TABLE statements.
We can check whether a table contains a generated column or not with the following methods.
Return Only Numeric Values in SQL
If you ever need to use SQL to return just the numeric values in a character column, the method you use will largely depend on your DBMS. Most DBMSs support regular expressions (regex), but some don’t. And some include functions that can detect numeric values.
Here are examples of how to do it in the more popular DBMSs.