Inserting, updating, and deleting rows
The INSERT
, UPDATE
, DELETE
, and SELECT
 operations are called Data Manipulation Language (DML) statements. INSERT
, UPDATE
, and DELETE
are also called write operations, or simply write(s). SELECT
is a read operation and is simply called read(s).
How to do it...
Let's look at each of them in detail. I am sure you will enjoy learning this. I would suggest that you try a few things on your own as well, later. By the end of this recipe, we will also have gotten to grips with truncating tables.
Inserting
The INSERT
statement is used to create new records in a table:
mysql> INSERT IGNORE INTO `company`.`customers`(first_name, last_name,country) VALUES ('Mike', 'Christensen', 'USA'), ('Andy', 'Hollands', 'Australia'), ('Ravi', 'Vedantam', 'India'), ('Rajiv', 'Perera', 'Sri Lanka');
Or you can explicitly mention the id
column, if you want to insert the specific id
:
mysql> INSERT IGNORE INTO `company`.`customers`(id, first_name, last_name,country) VALUES (1,...