How to select the value of `show global status like 'Com_stmt_pre%';`



  • I need to read this value in a bash script so want to "select" the value but I'm not sure how. Currently I run show global status like 'Com_stmt_pre%'; which returns:

    enter image description here

    But I need to actually select the value out.

    The closest variable I've found is SELECT variable_value FROM performance_schema.global_status WHERE VARIABLE_NAME = 'Prepared_stmt_count'; but the values are different.



  • A script method would be:

    $ v=$(mysql --skip-column-names -B -e  'show global status like "Com_stmt_prepare"')
    $ v="${v##*[:space:]}"
    $ echo $v
    0
    

    Note: information_schema.GLOBAL_STATUS is not in MySQL-8.0 so show global status needed to be used.




Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2