Insert Data into a Table
Learn how to insert data in the MySQL database.
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:
insert into customers (name) values ('John Woo');
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 ...