Getting data into and out of our database tables and updating, and deleting data when necessary is where we will spend most of our time when working with MariaDB.
To put data into our database, we use the INSERT
command. The basic syntax isas follows:
INSERT [INTO] <table_name> [(<column_name>[, column_name,...])] {VALUES | VALUE} ({expression|DEFAULT},...)[,(...),...];
As with the CREATE TABLE
command, the parts in angle brackets (<>
) are what we'll replace with our own values. The square brackets ([]
) are optional and the pipe character (|
) means or. The curly brackets ({}
) specify a section that is mandatory but for this there is a choice of the key word you can use. For example, the INTO
keyword is optional but makes the INSERT
line more readable and we can use the keyword VALUES
or VALUE
depending on whether or not we are inserting a column of information or multiple items but we must use one of them. Anywhere...