Inserting row records into a MySQL datasheet using INSERT statements

Source: Internet
Author: User

Inserting new data using INSERT statements

Syntax: INSERT [into] tbl_name [(Col_name,...)] VALUES (pression,...),...

INSERT [into] tbl_name SET col_name=expression, ...

Let's start by using the INSERT statement to increase the record, which is an SQL statement that you need to specify the table for which you want to insert the data row or put the values into rows. INSERT statements have several forms:

You can specify values for all columns:

For example:

shell> mysql –u root –p
mysql> use mytest;
mysql> insert into worker values(“tom”,”tom@yahoo.com”);

The word "into" is optional since the MySQL 3.22.5. (This also holds true for other forms of INSERT statements.) The values table must contain the value of each column in the table and is given in the order in which the columns in the table are stored. (Generally, this is the order in which the columns are defined when the table is created.) If you are not sure, you can use DESCRIBE tbl_name to view this order. )

Using multiple value tables, you can provide multiple rows of data at once.

Mysql>insert into worker values (' Tom ', ' tom@yahoo.com '), (' Paul ', ' paul@yahoo.com ');

Inserts with multiple value tables ... The form of values is supported in MySQL 3.22.5 or later versions.

You can give the column to which you want to assign a value, and then list the values. This is useful for records where you want to create only a few columns that require initial setup.

For example:

Mysql>insert into worker (name) VALUES (' Tom ');

Since MySQL 3.22.5, this form of INSERT also allows multiple value tables:

Mysql>insert into worker (name) VALUES (' Tom '), (' Paul ');

Columns that do not give a name in the list of columns will be given a default value.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.