Ubuntu Unleashed 2019 Edition: Covering 18.04, 18.10, 19.04

(singke) #1

compliant, whereas InnoDB tables are. Note that ACID compliancy is no easy
task: All the extra precautions incur performance overhead.


SQL Subqueries


Subqueries enable you to combine several operations into one atomic unit,
and they enable those operations to access each other’s data. By using SQL
subqueries, you can perform some extremely complex operations on a
database. In addition, using SQL subqueries eliminates the potential problem
of data changing between two operations as a result of another user
performing some operation on the same set of data. Both PostgreSQL and
MySQL have support for subqueries in this release of Ubuntu, but this was
not true in earlier releases.


Procedural Languages and Triggers


A procedural language is an external programming language that you can use
to write functions and procedures. With a procedural language, you can do
things that aren’t supported by simple SQL. A trigger enables you to define
an event that invokes the external function or procedure you have written. For
example, you can use a trigger to cause an exception if an INSERT statement


containing an unexpected or out-of-range value for a column is given.


For example, in the CD tracking database, you could use a trigger to cause an
exception if a user enters data that does not make sense. PostgreSQL has a
procedural language called PL/pgSQL. Although MySQL has support for a
limited number of built-in procedures and triggers, it does not have any
procedural language. It does have a feature called stored procedures that is
similar, but it doesn’t do quite the same thing.


Configuring MySQL


A free and stable version of MySQL is included with Ubuntu. MySQL is also
available from www.mysql.com. The software is available in source code,
binary, and APT format for Linux. (See Chapter 9, “Managing Software,” for
the details on adding (or removing) software.)


After you have MySQL installed, you need to initialize the grant tables, which
contain information about user accounts, or permissions to access any or all
databases and tables and column data within a database. You can do this by
issuing mysql_install_db as root. This command initializes the grant

Free download pdf