我正在尝试使用 bash 脚本从 MySQL 获取所有列。我希望它们存储在一个数组中。如果我这样写:
mysql -uroot -pPassword1 "select column_name
from information_schema.columns
where table_schema = 'dbName'
and table_name = 'tableName';"
Run Code Online (Sandbox Code Playgroud)
...我收到标识符名称太长的错误。如果我这样写:
mysql -uroot -pPassword1 <<- SMTH
select column_name
from information_schema.columns
where table_schema = 'dbName'
and table_name = 'tableName';
SMTH
Run Code Online (Sandbox Code Playgroud)
一切正常。但我无法将其输出到变量。有什么建议?