gpt4 book ai didi

mysql - 将值插入表 MySQL

转载 作者:行者123 更新时间:2023-11-29 05:54:31 25 4
gpt4 key购买 nike

我正在尝试通过 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

据我所知,通过在线查看我使用的是正确的语法。有什么想法吗?

最佳答案

根据 documentation,ADMIN 在除最新版本之外的所有版本中都是保留字。 .

通常,最好(也更容易)只用 ` 分隔表名和列名,而不是尽量避免使用它们。

即使您保持警惕,` 也会保护您免受新关键字造成冲突的可能性。

例子:

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

关于mysql - 将值插入表 MySQL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50882430/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com