Mysql Learning Series: Error: 1005 Error errno: 105_MySQL

Source: Internet
Author: User
Mysql Learning Series: Error: 1005 Error errno: 105 mysql Learning Series: Error: 1005 Error errno: 105

1. SQL script:

(Red indicates the modified script)

Create database if not exists insurance;
Use insurance;
Create table if not exists person (
Driver_id varchar (10 ),
Name varchar (30 ),
Address varchar (50 ),
Primary key (driver_id)
);
Create table if not exists car (
License varchar (30 ),
Model varchar (30 ),
Year smallint,
Primary key (license)
);
Create table if not exists
Accident (
Report_number varchar (10) primary key,
Date,
Location varchar (50)

);
Create table if not exists
Owns (
Driver_id varchar (10 ),
License varchar (30 ),
Primary key (driver_id, license ),
Foreign key (driver_id) references person (driver_id ),
Foreign key (license) references car (license)
);
Create table if not exists
Xukezheng (
Driver_id varchar (10 ),
Che varchar (10 ),
Report_number varchar (10 ),
Demage_amount smallint,
Primary key (driver_id, che, report_number ),
Foreign key (driver_id) references person (driver_id ),
Foreign key (report_number) references accident (report_number)
);
2. error:

The xukezheng table cannot be created when the SQL statement is executed.

3. error cause:

In the xukezheng table, report_number is referenced as a foreign key, which is not defined as a primary key in the accident. An error occurs.

From: http://hi.baidu.com/jbm3072/item/37eb8ed62e2e9053d63aae43

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.