MySQL 工作台插入语句不起作用
所以我最近一直在使用 MySQL,作为一个长期的 MSSQL 用户,我对它有点陌生。
我一直在使用工作台生成一些插入语句,虽然我确信它之前可以工作,但现在似乎遇到了问题。
当我右键单击表并选择“发送到 SQL 编辑器”,然后选择“插入语句”时,它会给出一些如下所示的 SQL:
INSERT INTO `mybigtable`.`itemcollection`
(`ID`,
`Type`,
`Name`,
`Description`,
`SomeID`)
VALUES
(
{ID: 123},
{Type: 1},
{Name: '123'},
{Description: '1234'},
{SomeID: 1}
);
这总是在 ID 值点抛出错误,表示它不理解 : 符号(请记住,我没有对其生成的代码进行任何修改)。现在,我在网上看到的 MySQL 的每个插入语句(以及我通常习惯的插入语句)在值之前都没有名称,值只包含值。如果我删除值之前的所有名称,则插入语句可以正常工作。
因此,虽然我自己构建插入语句是可以的,但“发送到 SQL 编辑器”不起作用似乎很奇怪。我在这里错过了一步吗?我的设置中是否有什么可能是错误的?如果它不能实际使用它们,为什么它会生成在值之前包含字段名称的 SQL?
呸,令人沮丧。
So I've been playing around with MySQL lately, and being a long time MSSQL user I'm a little new to it.
I've been using the workbench to generate some insert statements, and while I'm sure it was working before it seems to be having trouble now.
When I right click on a table and select "Send to SQL editor" and then select "Insert statement", it gives me some SQL that looks like:
INSERT INTO `mybigtable`.`itemcollection`
(`ID`,
`Type`,
`Name`,
`Description`,
`SomeID`)
VALUES
(
{ID: 123},
{Type: 1},
{Name: '123'},
{Description: '1234'},
{SomeID: 1}
);
This always throws an error at the ID value point, saying it doesnt understand the : symbol (keeping in mind I made no modifications to the code it generated). Now every insert statement I've seen online for MySQL (and insert statements I'm used to in general) dont have the names before the values, the values contain JUST the values. If I remove all the names from before the values, the insert statement works fine.
So while it's ok if I build the insert statements on my own, it seems odd that the "Send to SQL editor" just doesnt work. Am I missing a step here? Is there something in my settings that might be wrong? Why would it generate SQL with the field names before the values if it cant actually use them?
Bah, frustrating.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这些很可能是您手动输入自己的值的占位符。它不会自动知道您想要插入什么值,因此它无法为您填充整个查询。相反,它为您提供示例值,以便您知道需要输入什么类型的数据,然后您需要自己指定数据。 SQL Server 做同样的事情(右键单击表,脚本表,插入):
我相信有一个快捷键可以显示一个弹出窗口,您可以在其中输入模板值。也许MySQL编辑器中有类似的东西?我不知道。
Those are most likely placeholders for where you are to enter your own values manually. It doesn't know automatically what values you wanted to insert, so it can't populate the whole query for you. Instead, it gives you example values so you know what type of data needs to be inputted, then you need to specify the data yourself. SQL Server does the same thing (right-click table, script table as, insert):
And I believe there is a shortcut key to display a popup window where you can enter the template values. Perhaps there is a similar thing in the MySQL editor? I don't know.