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

Updating data

If we want to modify or replace the content of any row of a table, then we need to use the UPDATE command. We can modify single or multiple fields of a table.

Create mysql_09.sh to update the name of specified Id:

#!/bin/bash 
mysql -u user1 -pTest623@! <<MY_QUERY 
use testdb; 
UPDATE Authors SET Name = 'Mansi Joshi' WHERE Id = 1; 
select * from Authors; 
MY_QUERY 

Now, save the program and run it as follows:

          $ chmod +x mysql_09.sh
          $ ./mysql_09.sh
  

The output will be:

    Id    Name
    1     Mansi Joshi
    2     Charles Dickens
    3     Jane Austen
    4     George Orwell
    5     Oscan Wilde
  
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