How to do it...

The table contains the column definition:

mysql> CREATE TABLE IF NOT EXISTS `company`.`customers` (`id` int unsigned AUTO_INCREMENT PRIMARY KEY,`first_name` varchar(20),`last_name` varchar(20),`country` varchar(20)) ENGINE=InnoDB;

The options are explained as follows:

  • Dot notation: Tables can be referenced using database name dot table name (database.table). If you are connected to the database, you can simply use customers instead of company.customers.
  • IF NOT EXISTS: If a table with the same name exists and you specify this clause, MySQL simply throws a warning that the table already exists. Otherwise, MySQL will throw an error.
  • id: It is declared as an integer since it contains only integers. Along with that, there are ...

Get MySQL 8 Cookbook now with the O’Reilly learning platform.

O’Reilly members experience live online training, plus books, videos, and digital content from nearly 200 publishers.