开发者

MySQL workbench insert statement not working

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 t开发者_如何学Pythono 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.


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):

INSERT INTO [5819338].[dbo].[Customer]
           ([ID]
           ,[Name])
     VALUES
           (<ID, int,>
           ,<Name, varchar(50),>)

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜