Insert Data into a Table
Explore how to insert data into MySQL tables using the SQL insert statement, including specifying columns and values. Learn to retrieve all or specific data columns with select queries for effective table management.
We'll cover the following...
Data insertion
Now that we have our customers table, we can insert data into it. The insert into <table_name> command is used to insert data in the table. Let’s do that with the customers table:
When we run this query in the MySQL command line we will get the following output which means the action was completed successfully. That’s why we should get “Succeeded” in the result box of the above query.
1 mysql> insert into customers (name) values ('John Woo');
2 Query OK, 1 row affected (0.01sec)
3
4 mysql>
Syntax of insert query
Let’s look at the query above, how it works, and how to use it.
In order to succeed, we need to give the list of columns in which we want to insert data. In our case, this is only the name column. We’ll also provide values with the values keyword and the list of actual values. In our case, this is only John Woo. The list of ...