Inserting Data
Explore how to add data into SQL tables using the INSERT statement. Learn to insert single or multiple records, use default values, and apply alternatives like the SET keyword to efficiently populate your database.
We'll cover the following...
Insert Data
In the previous lessons we created our example table, Actors. But a table without any data is not very useful. In this lesson we’ll learn how to add data into a table using the INSERT statement. We’ll retrieve the added rows using the SELECT keyword. We’ll learn more about using SELECT in the next lesson, but for now, it suffices to know that it is used for retrieving rows from a table.
Example Syntax
INSERT INTO table (col1, col2 … coln)
VALUES (val1, val2, … valn);
Connect to the terminal below by clicking in the widget. Once connected, the command line prompt will show up. Enter or copy and paste the command ./DataJek/Lessons/7lesson.sh and wait for the MySQL prompt to start-up.
-
Now we’ll add a row to our, so far empty, Actors table using the INSERT command. Copy ...