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

Drop the table

If we want to remove any particular table from a database, then we need to use the DROP TABLE command. This command will remove the table definition along with all related partition information.

Now we will create the script mysql_13.sh to drop the table:

#!/bin/bash 
mysql -u user1 -pTest623@! <<MY_QUERY 
use testdb; 
DROP TABLE Authors; 
MY_QUERY 

Save the program and run it as follows:

          $ chmod +x mysql_13.sh
          $ ./mysql_13.sh
  

After executing this script, your table will have been deleted. To check whether your table has been deleted, run this same script again, and you will get the following error message:

ERROR 1051 (42S02) at line 3: Unknown table 'testdb.Authors' 

This means that your table has successfully been deleted. ...

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