Here are five options for using SQL to return only those rows that have the maximum value within their group.
These examples work in most major RDBMSs, including MySQL, MariaDB, Oracle, PostgreSQL, SQLite, and SQL Server.
Continue readingDatabase Management Systems
Here are five options for using SQL to return only those rows that have the maximum value within their group.
These examples work in most major RDBMSs, including MySQL, MariaDB, Oracle, PostgreSQL, SQLite, and SQL Server.
Continue readingThe very useful CREATE TABLE IF NOT EXISTS
syntax was finally introduced in Oracle Database – Oracle Database 23c to be precise. This syntax allows us to run a CREATE TABLE
statement without getting an error if the table already exists.
Earlier versions of Oracle don’t support the IF NOT EXISTS
clause, and so if we want to avoid any nasty errors resulting from trying to create a table that already exists, we need to do a bit of extra work.
If you need to return all rows that don’t contain any numbers, the following might help.
Strictly speaking, numbers can be represented by words and other symbols, but for this article “number” simply means “numerical digit”. So we’re finding values that don’t contain any numerical digits.
Continue readingWhen using the TO_CHAR()
function in Oracle Database, you can use the RN
format element to return the number as roman numerals. Using lowercase (rn
) returns the roman numerals in lowercase.
Here are three examples that use SQL to find and select the row with the maximum value in a given column.
The examples work in most major RDBMSs, including MySQL, MariaDB, PostgreSQL, SQLite, Oracle, and SQL Server.
Continue readingIf you have a table with duplicate rows in PostgreSQL, you can use any of the following queries to return the duplicate rows.
Continue readingBelow are two methods for returning rows that only contain alphanumeric characters in Oracle Database.
Alphanumeric characters are alphabetic characters and numeric characters.
Continue readingBelow are four ways to list out the views in a MariaDB database using SQL or the command line.
Continue readingDropping a table in SQL easy. You simply use DROP TABLE myTable
where myTable
is the name of the table you want to drop. You can use this method to drop a table in SQL Server via T-SQL script.
But you’ll get an error if the table doesn’t actually exist. That is, unless you check for the existence of the table first.
Below are four ways of using T-SQL to check whether the table exists before dropping it.
Continue readingThe following options can be used to delete duplicate rows in SQLite.
These examples delete duplicate rows but keep one. So if there are three identical rows for example, it deletes two of them and keeps one. This is often referred to as de-duping the table.
Continue reading