If you have a column in a database table that contains character data, but some rows also contain numbers, you can use the following SQL queries to return just those rows that don’t contain numbers within the value.
Continue readingCategory: Oracle
SQL CASE Statement
In SQL, the CASE
statement evaluates a list of conditions and returns one of multiple possible result expressions.
In some ways, the SQL CASE
statement is kind of similar to the IF...ELSE
statement in that it allows us to check for a given condition and return a different result depending on the outcome.
SQL NULLIF() Explained
Most major RDBMSs support the NULLIF()
operator, which returns NULL
if both of its arguments are equivalent. If the arguments not equivalent, NULLIF()
returns the first argument.
NULLIF()
is a SQL-standard feature (it’s included in the ISO/IEC 9075 specification).
SQL COALESCE() Explained
Most major RDBMSs support the COALESCE()
operator, which returns the first non-null value from its list of arguments.
COALESCE()
is a SQL-standard feature (it’s included in the ISO/IEC 9075 specification).
6 Ways to Delete Duplicate Rows that have a Primary Key in Oracle
Here are some options for deleting duplicate rows from a table in Oracle Database when those rows have a primary key or unique identifier column.
In such cases, the primary key must be ignored when comparing duplicate rows (due to the fact that primary keys hold unique values).
Continue readingDetect Whether a Value Contains at Least One Numerical Digit in SQL
Sometimes you might need to search a database table for only those rows that contain at least one number in a given column.
Technically, numbers can be represented by words and other symbols, but here “number” means “numerical digit”.
Below are examples of how to find rows that contain at least one number in various SQL based DBMSs.
Continue readingOracle ISNULL() Equivalent
Most major DBMSs provide us with a function for replacing null values with another value.
But the name of the function tends to differ across DBMSs. For example, SQL Server has an ISNULL()
function, while others (such as MySQL, MariaDB, and SQLite) have an IFNULL()
function for doing the same thing.
However, to confuse matters, MySQL and MariaDB each have an ISNULL()
function that works differently to SQL Server’s function of the same name (MySQL and MariaDB’s implementation only accept a single argument, and return 1
if its null
and 0
if it’s not).
Convert a Unix Timestamp to a Date Value in Oracle
In Oracle Database, we can use the following technique to return a date from a Unix timestamp value.
The Unix timestamp (also known as Unix Epoch time, Unix time, or POSIX time) is the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC).
Continue reading2 Ways to Convert to Uppercase in Oracle
Below are two functions that convert lowercase characters to their uppercase equivalent in Oracle Database.
Both functions work in a similar way, but with a minor difference.
Continue readingHow to Return the Unix Timestamp in Oracle
Here’s an option for returning the Unix timestamp when using Oracle Database.
The Unix timestamp (also known as Unix Epoch time, Unix time, or POSIX time) is the number of seconds that have elapsed since 00:00:00 Thursday, 1 January 1970, Coordinated Universal Time (UTC).
Continue reading