Working with tables

Now we are going to create the necessary tables. First, we will run the USE statement to set eshop as our default database. This allows us to avoid specifying the database name in each statement, as explained in Chapter 1, Installing MariaDB.

MariaDB [(none)]> USE eshop;
Database changed

Then we can create our first table using CREATE TABLE. This command specifies concepts that have not yet been discussed, such as table types and storage engines. The following example shows the syntax of the statement, but we will leave out the details for now. All these concepts will be made clear by the end of this chapter.

CREATE TABLE catalogue
(
  id INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  name VARCHAR(50) NOT NULL,
 price DECIMAL(6, ...

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.