MySql Workbench SQL查询语法错误

时间:2021-10-21 23:11:27

I'm testing some simple scripts to get the feel of MySQL in Workbench. I've created a database called 'myschema' and am trying to execute the following script in the scripting shell

我正在测试一些简单的脚本,以便在Workbench中感受MySQL。我创建了一个名为'myschema'的数据库,并尝试在脚本shell中执行以下脚本

ALTER TABLE 'myschema'.'employee' DROP COLUMN 'date_of_birth' ;

However, I always get the following error:

但是,我总是收到以下错误:

Uncaught exception while executing C:\Users\Owner\AppData\Roaming\MySQL\Workbench\scripts\deletion.py: File "c:\users\owner\appdata\roaming\mysql\workbench\scripts\deletion.py", line 9

执行C:\ Users \ Owner \ AppData \ Roaming \ MySQL \ Workbench \ scripts \ deletion.py时未捕获异常:文件“c:\ users \ owner \ appdata \ roaming \ mysql \ workbench \ scripts \ deletion.py”,行9

ALTER TABLE 'myschema'.'employee' DROP COLUMN 'date_of_birth' ;

ALTER TABLE'myschema'。'employee'DROP COLUMN'date_of_birth';

SyntaxError: invalid syntax

SyntaxError:语法无效

This is a very basic command, so I'm confused as to why it's not working. I've tried getting rid of the quotes and the 'myschema' part, but I keep getting the same error. What am I doing wrong?

这是一个非常基本的命令,所以我很困惑为什么它不起作用。我已经尝试摆脱引号和'myschema'部分,但我一直得到同样的错误。我究竟做错了什么?

In fact, I've found that no SQL queries at all work in the scripting shell. They all return syntax errors

事实上,我发现在脚本shell中没有任何SQL查询工作。它们都返回语法错误

SOLVED: I was using the wrong editor. Was solved by using the SQL Query Editor instead of the Scripting Shell

解决:我使用错误的编辑器。通过使用SQL查询编辑器而不是Scripting Shell解决了

2 个解决方案

#1


1  

Simply use:

ALTER TABLE myschema.employee DROP COLUMN date_of_birth;

or if you had non standard identifiers or reserved keywords to escape, you could use backticks:

或者如果你有非标准的标识符或保留的关键字来逃避,你可以使用反引号:

ALTER TABLE `myschema`.`employee` DROP COLUMN `date_of_birth`;

#2


1  

Remember than you should to use back quote for identifiers:

请记住,您应该使用标记的背引号:

ALTER TABLE `myschema`.`employee` DROP COLUMN `date_of_birth` ;

#1


1  

Simply use:

ALTER TABLE myschema.employee DROP COLUMN date_of_birth;

or if you had non standard identifiers or reserved keywords to escape, you could use backticks:

或者如果你有非标准的标识符或保留的关键字来逃避,你可以使用反引号:

ALTER TABLE `myschema`.`employee` DROP COLUMN `date_of_birth`;

#2


1  

Remember than you should to use back quote for identifiers:

请记住,您应该使用标记的背引号:

ALTER TABLE `myschema`.`employee` DROP COLUMN `date_of_birth` ;