Skip to content

SQL Bits

You're here to find quick SQL recipes.

  • Home
  • Topics
    • Generic SQL
    • PostgreSQL
    • MariaDB
    • MySQL
    • Oracle
    • SQL Server
    • Db2
    • Informix
    • SQLite
  • Advertising
  • Write
  • About

Category: MariaDB

MariaDB/MySQL: How to get the first and last day of the month

Different databases support different ways to get the first and last day of the month. Let’s see how to do it in MariaDB and MySQL.

Continue reading MariaDB/MySQL: How to get the first and last day of the month
Published January 8, 2022
Categorized as MariaDB, MySQL Tagged level-beginner

MariaDB CRUD operations Hello World

Let’s see a slightly elaborated “Hello world”, to demonstrate the most common SQL operations with MariaDB: creating a database and a table, inserting a row, reading it, modifying it, deleting it.

Continue reading MariaDB CRUD operations Hello World
Published October 30, 2021
Categorized as MariaDB Tagged level-beginner

MariaDB: Rollback the transaction if a warning occurs

In MariaDB most errors cause the current transaction to rollback, but warnings don’t. This article shows how to rollback when a warning happens.

Continue reading MariaDB: Rollback the transaction if a warning occurs
Published October 13, 2021
Categorized as MariaDB Tagged level-intermediate

Copying tables in MariaDB and MySQL

There are many reasons why we may want to duplicate a table. We may want to copy the table structure alone, or include the rows, we may only want to copy some sample rows. Let’s see how to copy a table in MariaDB and MySQL.

Continue reading Copying tables in MariaDB and MySQL
Published September 9, 2021
Categorized as MariaDB, MySQL Tagged level-intermediate

MariaDB: Running a prepared statement in a stored procedure

How to run prepared statements in a MariaDB stored procedure. The article covers one-off prepared statements, reusable prepared statements, and parameters.

Continue reading MariaDB: Running a prepared statement in a stored procedure
Published August 19, 2021
Categorized as MariaDB Tagged level-intermediate

MariaDB/MySQL: Comments on database objects

MariaDB and MySQL support a non-standard syntax to read and write comments for database objects.

Continue reading MariaDB/MySQL: Comments on database objects
Published August 9, 2021
Categorized as MariaDB, MySQL Tagged level-intermediate

Find out if you’re running MariaDB, MySQL or Percona Server

MariaDB and MySQL are mostly compatible, while Percona Server is basically MySQL with some optimisations. For this reason, it’s quite common for developers not being sure which of them they are using.

Continue reading Find out if you’re running MariaDB, MySQL or Percona Server
Published July 27, 2021
Categorized as MariaDB, MySQL Tagged level-beginner

Find the maximum text length in a column

How to get the length of the longest text in a column. Including Db2 specific syntax.

Continue reading Find the maximum text length in a column
Published July 24, 2021
Categorized as Db2, Generic SQL, Informix, MariaDB, Oracle, PostgreSQL, SQL Server Tagged level-beginner

Create a cross-table unique ID

Most tables are created with a unique, progressive ID. But how to create an ID whose values are unique across multiple tables? For example, if value 1 is in table A, it must not be in table B.

Continue reading Create a cross-table unique ID
Published July 23, 2021
Categorized as Db2, Generic SQL, Informix, MariaDB, Oracle, PostgreSQL, SQL Server Tagged level-intermediate

MariaDB: Select the Fibonacci series

How to select the first N numbers from the Fibonacci series, or the Nth number from the series. This is done by using the SEQUENCE storage engine and user variables.

Continue reading MariaDB: Select the Fibonacci series
Published July 22, 2021
Categorized as MariaDB Tagged level-expert
  • Twitter
  • Email
SQL Bits
Proudly sponsored by Vettabase.