简体   繁体   中英

Creating a SQL script to insert data into a table (MySQL)

I sincerely apologize if this sounds like the most ridiculously beginner question, but I'm just starting to figure out SQL. It's more out of necessity than learning from the ground up. Thankyou for any help though, I sincerely appreciate it!

What I'm trying to do is create a script to insert data to the following table:

playercreateinfo_item.sql - github link to copy of the sql table

The fields/columns are race, class, itemid, amount.

How would I go about creating a script for this? From my basic understanding, it would be something like:

INSERT INTO playercreateinfo_item (race,class,itemid,amount)

VALUES (1,1,1,1);

But what else would I need? Like a header or footer? I'm honestly not even sure what a full script would look like for this! I also have to insert hundreds of different pieces of data, I'm not sure if there's an easy way to do it, or if I have to just do it manually. I'm so sorry if this is a horribly basic question, I'm just lost trying to learn. Thankyou so much in advance for any help! You guys are fantastic.

A SQL script is just a text file with SQL commands. Usually queries are separated with a semicolon.

No header or footer required.

Edit:

In case of inserting multiple tuples, you can do a batch insert with INSERT like this

INSERT INTO playercreateinfo_item (race,class,itemid,amount)
VALUES (1,1,1,1), (2,2,2,2), (3,3,3,3);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM