Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying MariaDb Essentials
  • Table Of Contents Toc
  • Feedback & Rating feedback
MariaDb Essentials

MariaDb Essentials

By : Kenler
4.5 (2)
close
close
MariaDb Essentials

MariaDb Essentials

4.5 (2)
By: Kenler

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 (10 chapters)
close
close
9
Index

Dealing with duplicates and consistency errors

Our product table does not have any UNIQUE index. However, at least one column should contain a unique value; in fact, it would be rather uncommon to have several products with the same name. So, let's add a UNIQUE index:

ALTER TABLE product ADD UNIQUE INDEX unq_name (name);

Now that we have a UNIQUE index, we can use it as an example to discuss how we can deal with duplicates with MariaDB.

Suppose that we want to add a new product, or modify an existing product. In both cases, there is a possibility that the new product name is already in use, causing a conflict. MariaDB supports several statements to automatically handle this conflict:

Syntax

Behavior

INSERT

MariaDB will simply reject the new row with an error that informs us about the problem. If we are inserting several rows with one statement, the whole statement will fail, and no rows will be added.

INSERT IGNORE

Ignore rows that cause an error. They will not be inserted,...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech
bookmark search playlist font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY