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

Example of mysql entering multiple lines at a time

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

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces mysql input multi-line example, with a certain reference value, friends can refer to the need. I hope you all have a lot to gain after reading this article. Let's take a look at it together.

mysql can insert multiple records at once through the insert statement, but this statement is a transaction, so it must succeed and fail. Each record in the statement is enclosed by ().

And the syntax is mysql itself, not standard syntax, can not be universal.

mysql inserts multiple pieces of data at once:

INSERT INTO hk_test(username, passwd) VALUES('qmf2', 'qmf2'),('qmf3', 'qmf3'),('qmf4', 'qmf4'),('qmf5', 'qmf5');

First, let's create a table Authors:

CREATE TABLE Authors(AuthID SMALLINT NOT NULL PRIMARY KEY,AuthFN VARCHAR(20),AuthMN VARCHAR(20),AuthLN VARCHAR(20))ENGINE=INNODB;

Then insert multiple pieces of data into the table at once, sql insert code is as follows:

INSERT INTO Authors VALUES (1006, 'H', 'S. ', 'T'), (1007, 'J', 'C', 'O'), (1008, 'B', NULL, 'E'), (1009, 'R', 'M', 'R'), (1010, 'J', 'K', 'T'), (1011, 'J', 'G. ', 'N'), (1012, 'A', NULL, 'P'), (1013, 'A', NULL, 'W'), (1014, 'N', NULL, 'A');

In fact, it is very similar to SQL statements inserted one by one, except that multiple insert statements use commas to separate each data.

The results were as follows:

AuthID

AuthFN

AuthMN

AuthLN

1006

H

S.T1007

J

CO1008

B

E1009

RMR1010

JKT1011

JG.N1012

A

p1013

A

W1014

N

A thank you for reading this article carefully, hope Xiaobian share mysql input multi-line example content to help everyone, but also hope that everyone more support, pay attention to the industry information channel, encounter problems to find, detailed solutions waiting for you to learn!

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