无法确定生成源表时出了什么问题。 ins_id似乎是造成此问题的原因。它是“自动增量”,因此我将其保留为空,并且机构表中的其他所有内容与源表中的其他内容相同。这是代码。

    -- MySQL Workbench Forward Engineering

SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0;
SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0;
SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='TRADITIONAL,ALLOW_INVALID_DATES';

-- -----------------------------------------------------
-- Schema tks15
-- -----------------------------------------------------
--
--
DROP SCHEMA IF EXISTS `tks15` ;

-- -----------------------------------------------------
-- Schema tks15
--
--
--
-- -----------------------------------------------------
CREATE SCHEMA IF NOT EXISTS `tks15` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ;
USE `tks15` ;

-- -----------------------------------------------------
-- Table `tks15`.`category`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `tks15`.`category` ;

CREATE TABLE IF NOT EXISTS `tks15`.`category` (
  `cat_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '',
  `cat_type` ENUM('salary', 'bonus', 'pension', 'social security', 'unemployment', 'disability', 'royalty', 'interest', 'dividend', 'tax return', 'gift', 'child support', 'alimony', 'award', 'grant', 'scholarship', 'inheritance', 'housing', 'food', 'transportation', 'charity', 'investment', 'insurance', 'clothing', 'saving', 'health', 'personal', 'recreation', 'debt', 'school', 'childcare', 'misc') NOT NULL COMMENT '',
  `cat_notes` VARCHAR(255) NULL COMMENT '',
  PRIMARY KEY (`cat_id`)  COMMENT '')
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `tks15`.`institution`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `tks15`.`institution` ;

CREATE TABLE IF NOT EXISTS `tks15`.`institution` (
  `ins_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '',
  `ins_name` VARCHAR(75) NOT NULL COMMENT '',
  `ins_street` VARCHAR(45) NOT NULL COMMENT '',
  `ins_city` VARCHAR(45) NOT NULL COMMENT '',
  `ins_state` VARCHAR(2) NOT NULL COMMENT '',
  `ins_zip` INT UNSIGNED NOT NULL COMMENT '',
  `ins_phone` BIGINT(10) UNSIGNED NOT NULL COMMENT '',
  `ins_email` VARCHAR(100) NOT NULL COMMENT '',
  `ins_url` VARCHAR(100) NOT NULL COMMENT '',
  `ins_contact` VARCHAR(45) NOT NULL COMMENT '',
  `ins_notes` VARCHAR(45) NULL COMMENT '',
  PRIMARY KEY (`ins_id`)  COMMENT '')
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `tks15`.`account`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `tks15`.`account` ;

CREATE TABLE IF NOT EXISTS `tks15`.`account` (
  `act_id` TINYINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '',
  `act_type` VARCHAR(20) NOT NULL COMMENT '',
  `act_notes` VARCHAR(255) NULL COMMENT '',
  PRIMARY KEY (`act_id`)  COMMENT '')
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `tks15`.`user`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `tks15`.`user` ;

CREATE TABLE IF NOT EXISTS `tks15`.`user` (
  `usr_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '',
  `usr_fname` VARCHAR(45) NOT NULL COMMENT '',
  `usr_lname` VARCHAR(45) NOT NULL COMMENT '',
  `usr_street` VARCHAR(45) NOT NULL COMMENT '',
  `usr_city` VARCHAR(45) NOT NULL COMMENT '',
  `usr_state` VARCHAR(2) NOT NULL COMMENT '',
  `usr_zip` INT UNSIGNED NOT NULL COMMENT '',
  `usr_phone` BIGINT(10) UNSIGNED NULL COMMENT '',
  `usr_email` VARCHAR(100) NULL COMMENT '',
  `usr_notes` VARCHAR(255) NULL COMMENT '',
  PRIMARY KEY (`usr_id`)  COMMENT '')
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `tks15`.`source`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `tks15`.`source` ;

CREATE TABLE IF NOT EXISTS `tks15`.`source` (
  `src_id` SMALLINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '',
  `ins_id` TINYINT UNSIGNED NOT NULL COMMENT '',
  `act_id` TINYINT UNSIGNED NOT NULL COMMENT '',
  `usr_id` SMALLINT UNSIGNED NOT NULL COMMENT '',
  `src_start_date` DATE NOT NULL COMMENT '',
  `src_end_date` DATE NOT NULL COMMENT '',
  `src_notes` VARCHAR(255) NULL COMMENT '',
  PRIMARY KEY (`src_id`)  COMMENT '',
  INDEX `fk_source_institution1_idx` (`ins_id` ASC)  COMMENT '',
  INDEX `fk_source_account1_idx` (`act_id` ASC)  COMMENT '',
  INDEX `fk_source_user1_idx` (`usr_id` ASC)  COMMENT '',
  CONSTRAINT `fk_source_institution1`
    FOREIGN KEY (`ins_id`)
    REFERENCES `tks15`.`institution` (`ins_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_source_account1`
    FOREIGN KEY (`act_id`)
    REFERENCES `tks15`.`account` (`act_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_source_user1`
    FOREIGN KEY (`usr_id`)
    REFERENCES `tks15`.`user` (`usr_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


-- -----------------------------------------------------
-- Table `tks15`.`transaction`
-- -----------------------------------------------------
DROP TABLE IF EXISTS `tks15`.`transaction` ;

CREATE TABLE IF NOT EXISTS `tks15`.`transaction` (
  `trn_id` MEDIUMINT UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '',
  `src_id` SMALLINT UNSIGNED NOT NULL COMMENT '',
  `cat_id` MEDIUMINT UNSIGNED NOT NULL COMMENT '',
  `trn_type` ENUM('credit', 'debit') NOT NULL COMMENT '',
  `trn_method` VARCHAR(15) NOT NULL COMMENT '',
  `trn_amount` DECIMAL NOT NULL COMMENT '',
  `trn_date` DATE NOT NULL COMMENT '',
  `trn_time` TIMESTAMP NOT NULL COMMENT '',
  `trn_notes` VARCHAR(255) NULL COMMENT '',
  PRIMARY KEY (`trn_id`)  COMMENT '',
  INDEX `fk_transaction_category_idx` (`cat_id` ASC)  COMMENT '',
  INDEX `fk_transaction_source1_idx` (`src_id` ASC)  COMMENT '',
  CONSTRAINT `fk_transaction_category`
    FOREIGN KEY (`cat_id`)
    REFERENCES `tks15`.`category` (`cat_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT `fk_transaction_source1`
    FOREIGN KEY (`src_id`)
    REFERENCES `tks15`.`source` (`src_id`)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB;


SET SQL_MODE=@OLD_SQL_MODE;
SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS;
SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS;

-- -----------------------------------------------------
-- Data for table `tks15`.`category`
-- -----------------------------------------------------
START TRANSACTION;
USE `tks15`;
INSERT INTO `tks15`.`category` (`cat_id`, `cat_type`, `cat_notes`) VALUES (DEFAULT, 'misc', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`category` (`cat_id`, `cat_type`, `cat_notes`) VALUES (DEFAULT, 'tax return', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`category` (`cat_id`, `cat_type`, `cat_notes`) VALUES (DEFAULT, 'investment', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`category` (`cat_id`, `cat_type`, `cat_notes`) VALUES (DEFAULT, 'health', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`category` (`cat_id`, `cat_type`, `cat_notes`) VALUES (DEFAULT, 'personal', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');

COMMIT;


-- -----------------------------------------------------
-- Data for table `tks15`.`institution`
-- -----------------------------------------------------
START TRANSACTION;
USE `tks15`;
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'Goldman Sachs', '200 West St', 'New York', 'NY', 10001, 8507856541, 'goldman@goldmansachs.com', 'goldmansachs.com', 'brian.j.marchiony@jpmorgan.com', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'J.P Morgan', '270 Park Ave', 'New York', 'NY', 10001, 9874561478, 'jp@jpmorgan.com', 'jpmorgan.com', 'gs-investor-relations@gs.com', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'US Bank', '433 Hackensack St', 'Minneapolis', 'MN', 55401, 6321238795, 'help@usbank.com', 'usbank.com', 'usbankinvestor@usbank.com', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'Wells Fargo', '420 Montgomery St', 'San Francisco', 'CA', 94101, 8974561257, 'wellsfargo@wellsfargo.com', 'wellsfargo.com', 'cs@wellsfargo.com', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'Ally Financial', '17442 Herspania St', 'Detroit', 'MI', 48201, 7894584562, 'allyfinancial@ally.com', 'ally.com', 'contact@ally.com', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'PNC Financial Services', '523 Broadway St', 'Pittsburgh', 'PA', 15201, 4567821236, 'PNC@pnc.com', 'pnc.com', 'pnchelp@pnc.com', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'HSBC Bank USA', '107 Iris Glen Dr', 'Chicago', 'IL', 60290, 4569821287, 'ushsbc@us.hsbc.com', 'us.hsbc.com', 'contactus@us.hsbc.coom', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'Suntrust Bank', '303 Peachstreet St', 'Atlanta', 'GA', 30301, 6983578520, 'suntrust@suntrust.com', 'suntrust.com', 'help@suntrust.com', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`institution` (`ins_id`, `ins_name`, `ins_street`, `ins_city`, `ins_state`, `ins_zip`, `ins_phone`, `ins_email`, `ins_url`, `ins_contact`, `ins_notes`) VALUES (, 'Capital One', '1680 Capital One Dr', 'Mclean', 'VA', 32145, 7533574655, 'capitalone@capitalone.com', 'capitalone.com', 'abuse@capitalone.com', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');

COMMIT;


-- -----------------------------------------------------
-- Data for table `tks15`.`account`
-- -----------------------------------------------------
START TRANSACTION;
USE `tks15`;
INSERT INTO `tks15`.`account` (`act_id`, `act_type`, `act_notes`) VALUES (DEFAULT, 'saving', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`account` (`act_id`, `act_type`, `act_notes`) VALUES (DEFAULT, 'checking', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`account` (`act_id`, `act_type`, `act_notes`) VALUES (DEFAULT, 'mortgage', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`account` (`act_id`, `act_type`, `act_notes`) VALUES (DEFAULT, 'investments', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`account` (`act_id`, `act_type`, `act_notes`) VALUES (DEFAULT, 'mortgage', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');

COMMIT;


-- -----------------------------------------------------
-- Data for table `tks15`.`user`
-- -----------------------------------------------------
START TRANSACTION;
USE `tks15`;
INSERT INTO `tks15`.`user` (`usr_id`, `usr_fname`, `usr_lname`, `usr_street`, `usr_city`, `usr_state`, `usr_zip`, `usr_phone`, `usr_email`, `usr_notes`) VALUES (DEFAULT, 'John', 'Doe', '3803 Route 17', 'Berwen', 'IL', 60402, 7894562365, 'jd@example.com', NULL);
INSERT INTO `tks15`.`user` (`usr_id`, `usr_fname`, `usr_lname`, `usr_street`, `usr_city`, `usr_state`, `usr_zip`, `usr_phone`, `usr_email`, `usr_notes`) VALUES (DEFAULT, 'Opal ', 'Dane', '9985 Highland Ave', 'Port Jefferson Station', 'NY', 11767, 4561234789, NULL, NULL);
INSERT INTO `tks15`.`user` (`usr_id`, `usr_fname`, `usr_lname`, `usr_street`, `usr_city`, `usr_state`, `usr_zip`, `usr_phone`, `usr_email`, `usr_notes`) VALUES (DEFAULT, 'Peta ', 'Kayleen', '8151 Academy St', 'Chipoee', 'MA', 01020, NULL, 'pk@example.com', NULL);
INSERT INTO `tks15`.`user` (`usr_id`, `usr_fname`, `usr_lname`, `usr_street`, `usr_city`, `usr_state`, `usr_zip`, `usr_phone`, `usr_email`, `usr_notes`) VALUES (DEFAULT, 'Brenda ', 'Delora', '9132 Poplar City', 'Salt Lake City', 'UT', 84119, NULL, NULL, NULL);
INSERT INTO `tks15`.`user` (`usr_id`, `usr_fname`, `usr_lname`, `usr_street`, `usr_city`, `usr_state`, `usr_zip`, `usr_phone`, `usr_email`, `usr_notes`) VALUES (DEFAULT, 'Ozzie', 'Nonie', '1534 Berkshire Dr', 'Encino', 'CA', 91316, 4561237845, NULL, NULL);
INSERT INTO `tks15`.`user` (`usr_id`, `usr_fname`, `usr_lname`, `usr_street`, `usr_city`, `usr_state`, `usr_zip`, `usr_phone`, `usr_email`, `usr_notes`) VALUES (DEFAULT, 'Brandon ', 'Jimmie', '7738 Durham Ct', 'Hartford', 'CT', 06106, 8974269876, 'bj@example.com', NULL);

COMMIT;


-- -----------------------------------------------------
-- Data for table `tks15`.`source`
-- -----------------------------------------------------
START TRANSACTION;
USE `tks15`;
INSERT INTO `tks15`.`source` (`src_id`, `ins_id`, `act_id`, `usr_id`, `src_start_date`, `src_end_date`, `src_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, '2015-10-10', '2015-10-11', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`source` (`src_id`, `ins_id`, `act_id`, `usr_id`, `src_start_date`, `src_end_date`, `src_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, '2015-10-11', '2015-10-12', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`source` (`src_id`, `ins_id`, `act_id`, `usr_id`, `src_start_date`, `src_end_date`, `src_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, '2015-10-13', '2015-10-14', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`source` (`src_id`, `ins_id`, `act_id`, `usr_id`, `src_start_date`, `src_end_date`, `src_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, '2015-10-15', '2015-10-16', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`source` (`src_id`, `ins_id`, `act_id`, `usr_id`, `src_start_date`, `src_end_date`, `src_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, '2015-10-17', '2015-10-18', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');

COMMIT;


-- -----------------------------------------------------
-- Data for table `tks15`.`transaction`
-- -----------------------------------------------------
START TRANSACTION;
USE `tks15`;
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'credit', 'atm', 10.00, '2015-09-28', '11:59:59', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'credit', 'check ', 359.23, '2015-09-29', '08:23:12', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'debit', 'bank', 20.00, '2015-09-30', '06:00:58', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'credit', 'pos', 6.23, '2015-10-01', '07:12:16', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'debit', 'atm', 10.00, '2015-10-02', '08:23:56', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'debit', 'pos', 59.99, '2015-10-05', '09:15:01', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'credit', 'check', 423.25, '2015-10-06', '10:15:45', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'debit', 'transfer', 500.00, '2015-10-08', '05:45:12', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'debit', 'bank', 5.00, '2015-10-09', '11:59:59', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');
INSERT INTO `tks15`.`transaction` (`trn_id`, `src_id`, `cat_id`, `trn_type`, `trn_method`, `trn_amount`, `trn_date`, `trn_time`, `trn_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, 'credit', 'pos', 1.23, '2015-10-10', '12:42:45', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,');

COMMIT;


这是错误代码

ERROR: Error 1452: Cannot add or update a child row: a foreign key constraint fails (`tks15`.`source`, CONSTRAINT `fk_source_institution1` FOREIGN KEY (`ins_id`) REFERENCES `institution` (`ins_id`) ON DELETE NO ACTION ON UPDATE NO ACTION)
SQL Code:
        INSERT INTO `tks15`.`source` (`src_id`, `ins_id`, `act_id`, `usr_id`, `src_start_date`, `src_end_date`, `src_notes`) VALUES (DEFAULT, DEFAULT, DEFAULT, DEFAULT, '2015-10-10', '2015-10-11', 'Lorem ipsum dolor sit amet, nec vocent forensibus ei. Cu graeco copiosae vim, est veri dolorem placerat ne. Quaeque deterruisset ea qui,')

最佳答案

在插入“源”表时,“ ins_id”列必须已经在“机构”表的“ ins_id”列中已经存在一个值..... DEFAULT在此不起作用

关于mysql - 无法创建我的SQL Workbench错误1452源表,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33205598/

10-09 17:39