19

Inserting Data

In this chapter, you will learn how to insert data into tables by using the SQL INSERT statement.

Understanding Data Insertion

SELECT is undoubtedly the most frequently used SQL statement (which is why the past 15 chapters are dedicated to it). But there are three other frequently used SQL statements that you should learn. The first one is INSERT. (You’ll 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’ll now look at each of these.

Note

INSERT and System Security Use of the INSERT statement ...

Get MySQL Crash Course, 2nd Edition 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.