Database Reference
In-Depth Information
19
In this chapter, you learn how to insert data into tables using the SQL
INSERT
statement.
SELECT
is undoubtedly the most frequently used SQL statement (which is
why the past 18 chapters were dedicated to it). But there are three other fre-
quently used SQL statements that you should learn. The first one is
INSERT
.
(You get to the other two in the next chapter.)
As its name suggests,
INSERT
is used to insert (add) rows to a database table.
Insert can be used in several ways:
To insert a single complete row
■
To insert a single partial row
■
To insert multiple rows
■
To insert the results of a query
■
We look at each of these in the following sections.
Tip
INSERT
and System Security Use of the
INSERT
statement can be disabled
per table or per user using MariaDB security, as explained in Chapter 28, “Managing
Security.”
The simplest way to insert data into a table is to use the basic
INSERT
syntax,
which requires that you specify the table name and the values to be inserted
into the new row. Here is an example of this: