Database Reference
In-Depth Information
cust_country)
VALUES('Pep E. LaPew',
NULL,
NULL,
'100 Main Street',
'Los Angeles',
'CA',
'90046',
'USA');
Tip
Always Use a Columns List As a rule, never use INSERT without explicitly specifying
the column list. This greatly increases the probability that your SQL will continue to func-
tion in the event that table changes occur.
Caution
Use VALUES Carefully Regardless of
the INSERT syntax being used, the correct
number of VALUES must be specified. If no column names are provided, a value must
be present for every table column. If columns names are provided, a value must be pres-
ent for each listed column. If none is present, an error message will be generated, and
the row will not be inserted.
Using this syntax, you can also omit columns. This means you provide values
only for some columns, but not for others. (You've actually already seen an
example of this, cust_id was omitted when column names were explicitly
listed.)
Caution
Omitting Columns You may omit columns from an INSERT operation if the table
defi-
nition so allows. One of the following conditions must exist:
The column is defined as allowing NULL values (no value at all).
A default value is specified in the table definition. This means the default value
will be used if no value is specified.
If you omit a value from a table that does not allow NULL values and does not have a
default, MariaDB generates an error message, and the row is not inserted.
Tip
Improving Overall Performance Databases
are frequently accessed by multiple clients,
and it is MariaDB's job to manage which requests are processed and in which order.
INSERT operations can be time consuming (especially if there are many indexes to
be updated), and this can hurt the performance of SELECT statements waiting to be
processed.
 
Search WWH ::




Custom Search