问题
I need to execute from mysql shell an SQL file based on a condition like mysql> source @var where @var contains the filename
回答1:
This is not possible. source
is a command that is recognized and executed locally by the MySQL client program. Variables exist on the server, so the client has no idea what @variable
means.
来源:https://stackoverflow.com/questions/1638654/how-do-i-use-mysql-source-command-with-a-mysql-variable