MariaDB Sharding

MariaDB Sharding

In this MariaDB tutorial, we will discuss the concept of MariaDB Sharding and look at several related examples. MariaDB Sharding Sharding is a MariaDB technique for dividing a single database server into many pieces. This post will teach you how to shard in the simplest of ways. Each schema is on its database server, and … Read more >>

MariaDB Import CSV: LOAD DATA INFILE, Errors and Fixes

MariaDB import CSV with LOAD DATA INFILE and STR_TO_DATE in VS Code

Error: That’s what my first plain CSV import into MariaDB returned. The CSV was fine. A DATE column only takes YYYY-MM-DD, and the file had US dates. Quick answer: for a MariaDB import CSV, run LOAD DATA INFILE with the delimiter, quote, line ending and header rule, and convert dates in SET: Tested on MariaDB … Read more >>

MariaDB GREATEST and LEAST: NULLs, Dates and Per-Group Max

MariaDB GREATEST and LEAST across sales quarter columns in VS Code

MariaDB GREATEST(q1, q2, q3) returns the largest argument in one row; LEAST() returns the smallest. My verdict: right tool for “best quarter per rep”, but one NULL argument makes the result NULL. Quick answer: SELECT name, GREATEST(q1, q2, q3) FROM reps; For the top row per group, use ROW_NUMBER(). Tested on MariaDB 13.0.2, Windows 11; … Read more >>

MariaDB Comment: Syntax, Table and Column Comments

MariaDB MODIFY column comment dropping NOT NULL and DEFAULT in VS Code

A MariaDB comment starts with # or a double dash plus a space (– ) and runs to the end of the line, or sits between /* and */ across lines: Three result sets came back: The last line is an executable comment: MariaDB runs the +1, other databases skip it. Tested on MariaDB 13.0.2 on … Read more >>

MariaDB UNION and UNION ALL: ORDER BY, SUM, INTERSECT, EXCEPT

MariaDB UNION vs UNION ALL with SUM per state, run in VS Code

You’ve got one table of in-store orders and one of web orders, and you want a single list. MariaDB UNION stacks the rows of two SELECTs into one result and drops duplicate rows. That last part bites. I summed amounts over a plain UNION while building this demo, and two identical $89.50 orders collapsed into … Read more >>

MariaDB DATEDIFF: Days, Hours and Months Between Two Dates

MariaDB DATEDIFF vs TIMESTAMPDIFF HOUR and MINUTE in VS Code

MariaDB DATEDIFF(expr1, expr2) returns expr1 minus expr2 in whole days. It ignores the time part: The client printed: Swap them and you get a negative number. Two times only one minute apart, on either side of midnight, still count as a full day, because the function looks at nothing but the calendar date. Tested on … Read more >>

MariaDB IF: IF() Function in SELECT and IF ELSE Statement

MariaDB IF function inside SUM with GROUP BY in VS Code

I wrote an IF … THEN inside a SELECT on MariaDB 13.0.2. It failed: MariaDB’s reply: Quick answer: a MariaDB IF inside a query must be the IF() function, IF(amount >= 100, ‘big’, ‘small’), because the IF-THEN statement only runs in a stored program or a BEGIN NOT ATOMIC block. Tested on MariaDB 13.0.2 on … Read more >>

MariaDB Logs – Helpful Guide

MariaDB Logs

In this MariaDB tutorial, we will learn about “MariaDB logs” which means we will learn about many log files in MariaDB like error log, slow query log, and how to deal with these log files. Additionally, we will cover the following topics. MariaDB Logs MariaDB Logs Windows MariaDB Logs Ubuntu MariaDB Logs Location MariaDB Logs … Read more >>

MariaDB ENUM – Helpful Guide

MariaDB enumeration datatype example

In this MariaDB tutorial, we will look at how to utilize the MariaDB ENUM datatype and look at several examples. There are lists of the topic that comes under discussion: MariaDB enum MariaDB enum type MariaDB enum vs set MariaDB enum size MariaDB enum vs tinyint MariaDB add enum value MariaDB change enum MariaDB enum … Read more >>

MariaDB Queries – Detailed Guide

MariaDB Multiple Queries

In this MariaDB tutorial, you will learn about MariaDB Queries. Additionally, we will cover the following topics. MariaDB Queries MariaDB Queries Per Second MariaDB Queries Log MariaDB Queries Slow MariaDB Multiple Queries MariaDB Stacked Queries MariaDB SQL Queries MariaDB max_queries_per_hour MariaDB Log and Show All Queries MariaDB Show Active Queries MariaDB Kill All Queries MariaDB … Read more >>