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
Credits
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Index

Working with full-text indexes


In order to perform full-text searches on a table, you must index the data. In MariaDB, the type of index used for full-text searches is named FULLTEXT.

A full-text index can only be created on a column of type CHAR, VARCHAR, or TEXT.

As with the other indexes, the FULLTEXT index can be created by using CREATE TABLE when creating a new table, or by using ALTER TABLE or CREATE INDEX on an already existing table.

The following code will create a table, posts, with a full-text index on the content column:

CREATE TABLE `posts` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `title` varchar(255) NOT NULL,
  `content` text,
  PRIMARY KEY (`id`),
  FULLTEXT (`content`)
) ENGINE=InnoDB;

If you already have a table without a full-text index, there are two ways of adding a full-text index to a column. One way is by using ALTER TABLE:

ALTER TABLE `posts` ADD FULLTEXT(`content`);

The other way is by using CREATE INDEX:

CREATE FULLTEXT INDEX `content` ON `posts` (`content`);

If...