向表中插入值

8yparm6h  于 2021-06-20  发布在  Mysql
关注(0)|答案(1)|浏览(300)

我试图通过mysql给出的命令提示符手动将值插入表中。我正在使用的表是:

mysql> describe permissions;
+---------------------------+------------+------+-----+---------+----------------+
| Field                     | Type       | Null | Key | Default | Extra          |
+---------------------------+------------+------+-----+---------+----------------+
| id                        | int(11)    | NO   | PRI | NULL    | auto_increment |
| user_id                   | int(11)    | NO   | UNI | NULL    |                |
| admin                     | tinyint(1) | NO   |     | NULL    |                |
| quote_view                | tinyint(1) | NO   |     | NULL    |                |
| quote_create              | tinyint(1) | NO   |     | NULL    |                |
| quote_edit                | tinyint(1) | NO   |     | NULL    |                |
| inventory_edit            | tinyint(1) | NO   |     | NULL    |                |
| workorder_view            | tinyint(1) | NO   |     | NULL    |                |
| workorder_create          | tinyint(1) | NO   |     | NULL    |                |
| workorder_edit            | tinyint(1) | NO   |     | NULL    |                |
| reassign_wo               | tinyint(1) | NO   |     | NULL    |                |
| trucking_schedule_view    | tinyint(1) | NO   |     | NULL    |                |
| trucking_schedule_edit    | tinyint(1) | NO   |     | NULL    |                |
| production_schedule_view  | tinyint(1) | NO   |     | NULL    |                |
| production_schedule_basic | tinyint(1) | NO   |     | NULL    |                |
| production_schedule_sn    | tinyint(1) | NO   |     | NULL    |                |
| production_schedule_wip   | tinyint(1) | NO   |     | NULL    |                |
| serial_table_list_price   | tinyint(1) | NO   |     | NULL    |                |
+---------------------------+------------+------+-----+---------+----------------+

我正在尝试向具有 user_id =1通过执行以下命令:

mysql> INSERT INTO permissions
    -> (id, user_id, admin, quote_view, quote_create, quote_edit, inventory_edit, workorder_view, workorder_create, workorder_edit, reassign_wo, trucking_schedule_view, trucking_schedule_edit, production_schedule_view, production_schedule_basic, production_schedule_sn, production_schedule_wip, serial_table_list_price)
    -> VALUES
    -> ('1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1','1');

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

ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'admin, quote_view, quote_create, quote_edit, inventory_edit, workorder_view, wor' at line 2

就我在网上看到的情况来看,我使用的语法是正确的。有什么想法吗?

byqmnocz

byqmnocz1#

文档显示,除了最新版本外,admin在所有版本中都是保留字。
通常,最好(也更容易)只是用来分隔表和列名,而不是尽量避免使用它们。 即使你很警惕,会保护你免受新关键字引发冲突的可能。
例子:

INSERT INTO `permissions` (`id`, `user_id`, `admin`, `quote_view`, and so on...

相关问题