Skip to Content
Learning Linux Shell Scripting - Second Edition
book

Learning Linux Shell Scripting - Second Edition

by Ganesh Sanjiv Naik
May 2018
Beginner
332 pages
7h 28m
English
Packt Publishing
Content preview from Learning Linux Shell Scripting - Second Edition

Inserting data into table

Now we will insert some data into our Authors table. We will use insert into query to insert the data. Create the script 7_insert_into_Authors.sh to insert the data:

#!/bin/bash 
mysql -u user1 -pTest623@! <<MY_QUERY 
use testdb; 
Insert into Authors(NAME)values('William Shakespeare'); 
Insert into Authors(NAME)values('Charles Dickens'); 
Insert into Authors(NAME)values('Jane Austen'); 
Insert into Authors(NAME)values('George Orwell'); 
Insert into Authors(NAME)values('Oscan Wilde'); 
MY_QUERY 

Now save the program and run it as follows:

          $ chmod +x mysql_07.sh
          $ ./mysql_07.sh
  

After executing this script, records will have been successfully inserted. To check this you will need to use the command select.

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Learning Linux Shell Scripting

Learning Linux Shell Scripting

Ganesh Sanjiv Naik
Linux Shell Scripting Cookbook - Third Edition

Linux Shell Scripting Cookbook - Third Edition

Clif Flynt, Sarath Lakshman, Shantanu Tushar

Publisher Resources

ISBN: 9781788993197Supplemental Content