Describing a table

If we need to know more about the overall information or query the execution plan of an entire table, we need to use the DESCRIBE command.

We will create the script to obtain the table structure:

mysql -u user1 -pTest623@!  <<MY_QUERY 
use testdb; 
desc Authors; 

Save the script and run it as follows:

          $ chmod +x
          $ ./

The output will be:

    Field Type  Null  Key   Default           Extra
    Id    int(11)     NO    PRI   NULL  auto_increment
    Name  varchar(25) YES   NULL  
    ADDRESS varchar(25)     YES   NULL

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.