Home > database >  run mySql commands from .txt file
run mySql commands from .txt file

Time:12-26

I have a text file that contains about 302 commands to be executed by mySql server, all of them are in a .txt file, arranged in the same way:

USE Plate;
INSERT INTO B (S, P) values ("BI","Bia")

USE Plate;
INSERT INTO B (S, P) values ("BS","Suw")

USE Plate;
INSERT INTO B (S, P) values ("BL","Lom")

how could I (cause copying and pasting them into mySQL workbench doesn't seem like the wisest idea) do all of them at once?

additional info (just to be sure I guess):

USE Plate;
INSERT INTO B (S, P) values ("BL","Lom")

those should be executed together.

CodePudding user response:

You seem to be working under limitations of your own invention.

There's no reason to paste just one line at a time into MySQL Workbench. Leaving aside other methods of loading the file, just copy and paste the entire file, redundant USE statements and all, into a Workbench query window and hit the Execute button.

MySQL Workbench will happily execute the entire script, line by line.

  • Related