I'm working on fixing a database and have a script for correcting several tables. For example, this works fine:
mysql -u $U -p$P -D$D <<< 'ALTER TABLE
xyz_tablename
DROPcolumnname
;'
I'm not really a SQL ace so I'm not sure how to fix this one, and I'm running into a syntax error when I try this
mysql -u $U -p$P -D$D <<< 'ALTER TABLE
drupal_url_alias
CHANGElanguage
language
VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';'
This SQL statement works fine:
ALTER TABLE
drupal_url_alias
CHANGElanguage
language
VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT ''
The problem is that your SQL statement contains single quotes and is placed in single quotes. This confuses the shell about where one quoted string ends and a new one starts.
Try this:
mysql -u $U -p$P -D$D <<< "ALTER TABLE drupal_url_alias CHANGE language language VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';"
I have placed the statement in double quotes. Note that double quotes are not equivalent to single quotes (eg variable interpolation takes place in double quotes, but not in single quotes), but in your particular case the only difference is that single quotes after DEFAULT
are kept intact.
Bash 中的单引号内不能有单引号。
您必须使用"
:
mysql -u $U -p$P -D$D <<< "ALTER TABLE drupal_url_alias CHANGE language language VARCHAR( 12 ) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL DEFAULT '';"
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.