Practical introduction to relational databases

Inserting data

Inserting data into a table can be done in a myriad of different ways, we're gonna learn 3 of them. Or rather 2.5.

To do an insert successfully, we need to know

  • where we're inserting to (which schema.table)
  • which columns we're inserting into in that table, which is going to make sense in a few minutes
  • what the data that we're inserting into there is

The three different methods that we're going to go through are:

  1. inserting data but leaving out some columns and we let the database figure out what should go there in the inserting with defaults section. This is the half part
  2. inserting one or more records where we specify what the data is in the bulk insert section
  3. and lastly inserting data into a table where the source is a select query from another table

First up, let's deal with the defaults.