为什么MGR需要用主键
更新:HHH   时间:2023-1-7


为什么MGR需要使用主键?针对这个问题,今天小编总结这篇有关MGR表的文章,希望能帮助更多想解决这个问题的朋友找到更加简单易行的办法。

验证MGR架构表需要使用主键,不然插入数据会报错。

mysql> show tables;

+--------------+

| Tables_in_dd | +--------------+ | a            | +--------------+ 1 row in set (0.00 sec) mysql> desc a; +-------+---------+------+-----+---------+-------+ | Field | Type    | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | id    | int(11) | YES  |     | NULL    |       | +-------+---------+------+-----+---------+-------+ 1 row in set (0.00 sec) mysql> insert into a values(1); ERROR 3098 (HY000): The table does not comply with the requirements by an external plugin. mysql> alter table a add primary key (id); Query OK, 0 rows affected (0.02 sec) Records: 0  Duplicates: 0  Warnings: 0 mysql> desc a; +-------+---------+------+-----+---------+-------+ | Field | Type    | Null | Key | Default | Extra | +-------+---------+------+-----+---------+-------+ | id    | int(11) | NO   | PRI | NULL    |       | +-------+---------+------+-----+---------+-------+ 1 row in set (0.01 sec) mysql> insert into a values(1); Query OK, 1 row affected (0.00 sec) mysql> insert into a values(1); Query OK, 1 row affected (0.00 sec) mysql> select * from a; +----+ | id | +----+ |  1 | +----+ 1 row in set (0.00 sec)

看完上述内容,你们对MGR架构表需要使用主键的原因大概了解了吗?如果想了解更多相关文章内容,欢迎关注天达云行业资讯频道,感谢各位的阅读!


返回MySQL数据库教程...