TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

MySQL

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:

  • If the column can accept NULL, it is set to NULL.
  • If the column has default constraint, it is set to the implicit default for the column data type if strict SQL mode is not enabled. If the strict mode is enabled, an error occurs.
  • To get the next available number in an AUTO_INCREMENT column, we can leave the column out of the column list in the INSERT statement.

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/

Related Posts

DataGrip Desktop Shortcut

MySQL /

Launch DataGrip on Windows

DataGrip Download

MySQL /

Install DataGrip IDE on Windows 11

MySQL Workbench Windows 11

MySQL /

New MySQL Connection in Workbench

MySQL Command-line Client

MySQL /

Command-Line MySQL Client

Start MySQL Client

MySQL /

Start MySQL Client on Windows 11

‹ MySQL Logical Operators› MySQL REPLACE Statement

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version