In MariaDB, the MEDIAN()
function returns the median value of a range of values.
We can use the MEDIAN()
function in our queries to get a column’s median value across its partition or the whole result set.
In MariaDB, the MEDIAN()
function returns the median value of a range of values.
We can use the MEDIAN()
function in our queries to get a column’s median value across its partition or the whole result set.
If you’re getting an error that reads something like “ERROR 1050 (42S01) at line 22: Table ‘Pets’ already exists” when trying to create a table in MariaDB, it’s most likely because there’s already a table in the database with the same name.
To fix this issue, either change the name of the table you’re trying to create, or check the existing table to see if it’s the one you actually need.
Continue readingSome RDBMSs provide an easy way for us to find out how many rows were affected by the last SQL statement. This can be handy when running INSERT
, UPDATE
, or DELETE
statements.
The method used depends on the DBMS we’re using. Below, I look at how some of the major DBMSs implement this functionality.
Continue readingWhen creating a table with SQL, we can specify that the table is only to be created if it doesn’t already exist. Doing this prevents any errors from occurring in the event that the table already exists.
Here are some examples of doing this in various RDBMSs.
Continue readingWe have several options when it comes to using SQL to clone a table in MariaDB. And we have the option to clone the table with data, or without data.
Here are three SQL options for cloning a table in MariaDB.
Continue readingWhen working with SQL, we can use the INSERT
statement to insert a new row into a table. But what if we want to insert more than one row?
Fortunately, we can still use the INSERT
statement. Below is a quick example that inserts multiple rows using SQL.
We can use MariaDB’s SHOW CREATE TABLE
statement to generate a CREATE TABLE
script for existing tables in the database. This allows us to recreate the table without having to manually type out the table’s definition.
The statement requires SELECT
privilege for the table.
We can use the SQL INSERT
statement to insert a row into a table. We can also use it to insert more than one row.
Below are seven ways to insert multiple rows into a table in SQL. Most of these examples should work in the major RDBMSs, with the possible exception of Oracle. But no worries, I’ve included an example just for Oracle.
Continue readingIf you have a table in MariaDB with a generated column, you can use the following methods to find out its definition.
Continue readingHere are five ways to see whether a table contains a generated column in MariaDB.
Continue reading