Using INSERT
To put data into our database, we use the INSERT
command. The basic syntax is as follows:
INSERT [INTO] <table_name> [(<column_name>[, <column_name>,...])] {VALUES | VALUE} ({<expression>|DEFAULT},...)[,(...),...];
As with the CREATE TABLE
command in the previous chapter, the parts of the syntax example within the angle brackets (<>
) are what we'll replace with our own values. The parts between the square brackets ([]
) are optional and the pipe character (|
) means or. The curly brackets ({}
) specify a mandatory section where there is a choice of the key word which you can use. For example, the INTO
keyword is optional but makes the INSERT
line more readable and we can use the keyword VALUE
or VALUES
depending on whether we are inserting a single column of information or multiple columns, but we must use one of them. Three dots (...
) represent the part where the previous part can be repeated.
The expression
part is the value that we want to put in...