Using the OCCUR table type

The OCCUR table type allows you to create a new view of a table. A new row will be created for each cell of the table, the row will contain the name of the row, the name of the column, and the value in the corresponding cell.

We will first create a standard table with some data for practice:

CREATE TABLE `visitors` (
  `year` char(4) NOT NULL,
  `Jan` int(10) NOT NULL DEFAULT '0',
  `Feb` int(10) NOT NULL DEFAULT '0',
  `Mar` int(10) NOT NULL DEFAULT '0',
  `Apr` int(10) NOT NULL DEFAULT '0',
  `May` int(10) NOT NULL DEFAULT '0',
  `Jun` int(10) NOT NULL DEFAULT '0',
  `Jul` int(10) NOT NULL DEFAULT '0',
  `Aug` int(10) NOT NULL DEFAULT '0',
  `Sep` int(10) NOT NULL DEFAULT '0',
  `Oct` int(10) NOT NULL DEFAULT '0',
 `Nov` int(10) ...

Get MariaDB Essentials now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.