如果我尝试导入路径中带有空格的 SQL 脚本,则找不到该文件。
mypsqluser=> \i /home/markus/Documents/Projekte/My App/Installation/server_sql_script.sql
/home/markus/Documents/Projekte/My: No such file or directory
我尝试使用反斜杠、双反斜杠或引号来转义它,但是也不起作用,请参阅:
mypsqluser=> \i /home/markus/Documents/Projekte/My\ App/Installation/server_sql_script.sql
/home/markus/Documents/Projekte/My: No such file or directory
mypsqluser=> \i "/home/markus/Documents/Projekte/My App/Installation/server_sql_script.sql"
"/home/markus/Documents/Projekte/My App/Installation/server_sql_script.sql": No such file or directory
只有路径中没有空格时它才有效。但是如果路径中有空格怎么办?
答案1
单引号就可以了;然后可以选择转义空格:\i '/home/markus/Documents/Projekte/My\ App/Installation/server_sql_script.sql'