Database Reference
In-Depth Information
Analysis
This statement creates the orderitems table that contains the individual
items that make up an order. (The order itself is stored in the orders table.)
The quantity column contains the quantity for each item in an order. In
this example, adding the text DEFAULT 1 to the column description instructs
MariaDB to use a quantity of 1 if no quantity is specified.
Caution
Functions Are Not Allowed Unlike most DBMSs, MariaDB (like MySQL) does not allow
the use of functions as DEFAULT values; only constants are supported.
Tip
Using DEFAULT Instead of NULL Values Many database developers use DEFAULT
values instead of NULL columns, especially in columns that will be used in calculations
or data groupings.
Engine Types
You may have noticed that the CREATE TABLE statements used thus far all
ended with a ENGINE=Aria statement.
Like every other DBMS, MariaDB has an internal engine that actually man-
ages and manipulates data. When you CREATE TABLE that engine is used to
actually create the tables, and when you SELECT or perform any other database
processing, the engine is used internally to process your request. And for the
most part, the engine is buried within the DBMS and you need not pay much
attention to it.
But unlike most other DBMSs, MariaDB does not come with a single engine.
Rather, it ships with several different engines (the ones that come with MySQL
as well as additional ones), all buried within the server, and all capable of exe-
cuting commands like CREATE TABLE and SELECT .
So why bother shipping multiple engines? Because each has different capabili-
ties and features, and being able to pick the right engine for a job gives you
unprecedented power and flexibility.
Of course, you are free to totally ignore database engines. If you omit the
ENGINE= statement, the default engine will be used, and most of your SQL
statements will work as is. But not all, and that is why this is important (and
why two different engines are used in the sample tables used in this topic).
 
 
Search WWH ::




Custom Search