Populating a table with different data types is a snap as long as you match the type and supply the expected format: Strings need to be enclosed in single quotes (though some RDBMSs allow you to mix and match), number literals are provided as-is, and so on.

Literal in programming context means “hard-coded value,” and you might have heard that this is a bad word in software development circles. Yet when SQL statements are constructed, prior to being submitted for execution, all the values (with the exception of these supplied by DEFAULT constraints) must be properly formatted literals.

Let's construct an INSERT statement for the BOOKS table:

           ‚‘SQL Bible’

A brief examination of the structure should tell you that the only required value you need to supply is BK_ID because it has a NOT NULL constraint on it; everything else can be populated with default NULLs:

INSERT INTO books (bk_id) VALUES (8)

The preceding statement will insert a new row into the table and leave all fields but one empty, filled with default NULLs signifying absence of any data. Any attempt to insert a new record without involving BK_ID will fail with an error message informing you that the RDBMS can't insert the value NULL into ...

Get Discovering SQL: A Hands-On Guide for Beginners now with O’Reilly online learning.

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