How to echo print statements while executing a sql script

前端 未结 6 1780
执笔经年
执笔经年 2020-12-09 00:58

We have a simple sql script which needs to be executed against a MySQL database and we would like print log statements on the progress of the script (e.g. Inserted 10 record

6条回答
  •  囚心锁ツ
    2020-12-09 01:30

    For mysql you can add \p to the commands to have them print out while they run in the script:

    SELECT COUNT(*) FROM `mysql`.`user`
    \p;
    

    Run it in the MySQL client:

    mysql> source example.sql
    --------------
    SELECT COUNT(*) FROM `mysql`.`user`
    --------------
    
    +----------+
    | COUNT(*) |
    +----------+
    |       24 |
    +----------+
    1 row in set (0.00 sec)
    

提交回复
热议问题