Database Table A: CREATE TABLE task_desc_tab ( id INT(11) PRIMARY KEY NOT NULL COMMENT 'Auto-increment primary key' AUTO_INCREMENT, <strong>taskname</strong> VARCHAR(200) NOT NULL COMMENT 'Task name', sqlname VARCHAR(20) NOT NULL COMMENT 'sql file name', params VARCHAR(5000) NOT NULL COMMENT 'Task parameters, in the format of a JSON string', updatetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP COMMENT 'Update time', detail VARCHAR(3000) COMMENT 'Some description information of the task, just for notes' ) ENGINE = InnoDB DEFAULT CHARSET = utf8; Database B: CREATE TABLE exec_plan_tab ( id INT(11) PRIMARY KEY NOT NULL AUTO_INCREMENT, <strong>taskname</strong> VARCHAR(200) NOT NULL, startdate DATE NOT NULL, enddate DATE NOT NULL, updatetime TIMESTAMP DEFAULT CURRENT_TIMESTAMP, CONSTRAINT exec_plan_tab_task_desc_tab_taskname_fk FOREIGN KEY (taskname) REFERENCES task_desc_tab (taskname) ) ENGINE = InnoDB DEFAULT CHARSET = utf8; Goal: Create a table so that taskname in table B is a foreign key. Refer to the taskname field in table A. When creating the table, the following error is reported:
After troubleshooting, we found the cause of the problem: taskname in table A must be modified with the UNIQUE field to ensure the uniqueness of the record and avoid ambiguity when referenced by table B. The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: js to achieve sliding carousel effect
>>: Use of Linux crontab command
Source: https://medium.com/better-programming, au...
Table of contents Dynamically change themes The f...
There are two ways to install MySQL 5.7. One is t...
This article uses examples to describe the add, d...
Download the rpm installation package MySQL offic...
Table of contents PXE implements unattended batch...
This article will explain the composition of the ...
I have been having this problem recently when desi...
On Saturday, the redis server on the production s...
Students who use Ansible know that Ansible only s...
Table of contents 1. DateTimePicker date selectio...
When designing H5 layout, you will usually encoun...
Problem [root@zh ~]# [root@zh ~]# [root@zh ~]# yu...
Preface We all know that MySQL uses server-id to ...
According to data analysis company Net Market Sha...