I want to save the query I wrote in mysql console to a .sql file... for example :
"CREATE TABLE Employee(id...,name...,salary);
"
I want to save the code instead of it's result. thanks
I want to save the query I wrote in mysql console to a .sql file... for example :
"CREATE TABLE Employee(id...,name...,salary);
"
I want to save the code instead of it's result. thanks
Pass the query in a variable and then execute it. This way, variable will hold the query and you'll be able to do whatever you want:
query="CREATE TABLE Employee(id...,name...,salary)";
mysql -u root -h localhost -P 3306 -p -e "$query"
echo $query >> query.sql
This'll print the data as well as populate a file query.sql
in your PWD. The above example is a part of a shell script.