Site icon TestingDocs.com

MySQL Insert Statement

Overview

In this tutorial, we will learn about the MySQL INSERT statement. There are multiple methods to get data into MySQL tables, the INSERT statement is the most common.

Syntax

INSERT statement uses the following syntax:

mysql> INSERT INTO  table_name (column_list)

              VALUES (comma_separated_value_list);

The number of columns and values must be the same. String and temporal data types column values must be enclosed in single quotes in the INSERT statement.

Multiple Inserts

The Syntax for multiple inserts into the table is as follows:

For example, the statement to insert three rows into the table:

mysql> INSERT INTO table_name (column_list)

              VALUES (values_list), (values_list), (values_list)

 

We can also omit some column names in the INSERT statement. In general, if a column has no default value, the effect of omitting it from the INSERT statement depends on whether it accepts NULL and other conditions:

Example

https://www.testingdocs.com/insert-data-into-a-mysql-database-table/

MySQL Tutorials

MySQL Tutorials on this website:

https://www.testingdocs.com/mysql-tutorials-for-beginners/

For more information on MySQL Database:

https://www.mysql.com/

Exit mobile version