eve_mf eve_mf - 25 days ago 17
MySQL Question

MySQL Workbench 6.0 - incorrect syntax template

I am new using MySQL Workbench, I am actually discovering it now.

I can't find a clear tutorial or documentation where they explain why it is this syntax.

I have a table, called chefs, with id, name and country columns. I want to populate this table, using MySQL Workbench, following the tutorial, I end up doing right click on the table I want to insert, then click "send to SQL editor", and then click on "Insert statement". When I do this, a template appears on my Query screen like this:

INSERT INTO `cooking_book_new`.`chefs`
(`id`,
`name`,
`country`)
VALUES
(<{id: }>,
<{name: }>,
<{country: }>);


enter image description here

I have checked and verified, that if I use the regular syntax I use to use for mysql it inserts the row:

INSERT INTO chefs (id, name, country) VALUES (1, 'chef1', 'Country1');


But, as the whole point of trying to use this software is to make everything easier, I would like to know why it prepares that query, and how should I introduce the data there.

I have tried this:

INSERT INTO `cooking_book_new`.`chefs`
(`id`,
`name`,
`country`)
VALUES
(<{1}>,
<{'chef1'}>,
<{'country1'}>);


And also this:

INSERT INTO `cooking_book_new`.`chefs`
(`id`,
`name`,
`country`)
VALUES
(<{id:1 }>,
<{name:'chef1' }>,
<{country:'country1' }>);


But everything seems wrong. Does anyone know how to use this syntax? I know I could just do the query as I have tested that works like:

INSERT INTO chefs (id, name, country) VALUES (1, 'chef1', 'Country1');


But it would be better if I understand how MySQL workbench works.

Thank you!

Answer

The manual for Workbench probably contains an explanation for it, but given that it is so large, it would (probably) take (me) much longer to keep searching, as I did and finding something on their website with similar syntax.

As per the manual:

https://dev.mysql.com/doc/workbench/en/wb-generating-sql.html

The <{}> are only representational (expressions) values.

For example:

Update Statement

UPDATE `sakila`.`actor`
SET
`first_name` = <{first_name}>
WHERE <{where_expression}>;

Let's look at the manual on INSERT:

http://dev.mysql.com/doc/refman/5.7/en/insert.html

You're not going to use {VALUES | VALUE} or the rest of those [...] right? Those are "options".

INSERT [LOW_PRIORITY | DELAYED | HIGH_PRIORITY] [IGNORE]
    [INTO] tbl_name
    [PARTITION (partition_name,...)]
    [(col_name,...)]
    {VALUES | VALUE}

It is up to you to replace those "representational" values with the proper syntax, that needs to be used in conjunction with the reference manual.

Comments