Reputation: 2414
I already know that in order to make Mysql understands a keyword as a column name we should add back ticks.
I am trying to execute this command from a shell script
echo "ALTER TABLE partners.partners CHANGE COLUMN `name` `client_name` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL" | $MYSQL
Where $MYSQL
is my databse connection command (which works fine for other commands).
What I am trying to do is rename the colomn named name
to client_name
but I have got this error :
./test_script.sh: 1: ./test_script.sh: name: not found
If I log to mysql console , execute the same thing , It works perfectly
Any one run into this problem before ?
Upvotes: 2
Views: 70
Reputation: 785058
Use single quotes to avoid interpretation of back-tick or ` which is otherwise used for command substitution:
$MYSQL -e 'ALTER TABLE partners.partners CHANGE COLUMN `name` `client_name` varchar(150) COLLATE utf8_unicode_ci DEFAULT NULL'
Upvotes: 2