Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to add rows to mysql

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)05/31 Report--

This article mainly explains "how to increase the line of mysql". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn "how to increase the line of mysql".

Mysql method to add rows: 1, use "INSERT INTO table name column name 1, … column name n VALUES (value 1 …, value n);" statement, column name and value corresponding to the order; 2, use "INSERT INTO table name SET column name 1 = value 1, column name 2 = value 2, …;" statement to insert a row of data.

The operating environment of this tutorial: windows7 system, mysql8 version, Dell G3 computer.

In mysql, adding rows means inserting a row of data into a table in the database. The following article introduces you to two methods.

Method 1. Use INSERT. VALUES statement

The syntax format is:

INSERT INTO [,... ]] VALUES (value 1 [… , value n])

The syntax is as follows:

Table name: specifies the name of the table being manipulated.

Column name: specifies the name of the column in which data needs to be inserted. If you insert data into all the columns in the table, all column names can be omitted and directly use INSERTVALUES (...) That's it.

VALUES or VALUE clause: this clause contains the list of data to insert. The order of the data in the data list corresponds to the order of the columns.

Method 2: use INSERT … SET statement

The syntax format is:

INSERT INTO SET =, =,...

This statement is used to directly assign the corresponding column value to some columns in the table, that is, the column name of the data to be inserted is specified in the SET clause, col_name is the specified column name, the equal sign is followed by the specified data, and for unspecified columns, the column value is specified as the default value for that column.

Example:

Insert values: advantages: can be inserted in batches; disadvantages: single execution efficiency is low.

Insert into table (col1,col2,col3) values ('val1','val2','val3')

Insert set: advantages: high execution efficiency; disadvantages: only one piece of data can be inserted at a time.

Insert into table set col1='val1',col2='val2',col3='val3'

Thank you for your reading, the above is the content of "how to increase the line of mysql", after the study of this article, I believe you have a deeper understanding of how to increase the line of mysql, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report