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:

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

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

Get Learning Linux Shell Scripting - Second Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.