Book Image

MariaDb Essentials

Book Image

MariaDb Essentials

Overview of this book

This book will take you through all the nitty-gritty parts of MariaDB, right from the creation of your database all the way to using MariaDB’s advanced features. At the very beginning, we show you the basics, that is, how to install MariaDB. Then, we walk you through the databases and tables of MariaDB, and introduce SQL in MariaDB. You will learn about all the features that have been added in MariaDB but are absent in MySQL. Moving on, you’ll learn to import and export data, views, virtual columns, and dynamic columns in MariaDB. Then, you’ll get to grips with full-text searches and queries in MariaDb. You’ll also be familiarized with the CONNECT storage engine. At the end of the book, you’ll be introduced to the community of MariaDB.
Table of Contents (15 chapters)
MariaDB Essentials
About the Authors
About the Reviewers

Using the PIVOT table type

The PIVOT table type allows you to do exactly the reverse operation of the OCCUR table. Let's start by creating a copy of our data in a new table.

CREATE TABLE xvisitors2 (
  year char(4) NOT NULL,
  month char(3) NOT NULL,
  number int(10) NOT NULL
INSERT INTO xvisitors2 SELECT * FROM xvisitors;

Now we can create a new PIVOT table:


You should now be used to the TABLE_TYPE and TABNAME options, which specify the table type and the source table respectively.


If you have issues when creating this table, and get an Access denied error, please consult the documentation about proxy on non-CONNECT tables at

You can now run the following query to check if the PIVOT operation has been realized:

SELECT * FROM pvisitors;

Since we didn't specify any option when creating the table, MariaDB considered the last...