以下是sql腳本原始碼。運行不了。自己搞了2天實在搞不懂了到底啥毛病。。。

alter table student
drop foreign key FK_STUDENT_RELATIONS_SCHOOL;
alter table student
drop foreign key FK_STUDENT_RELATIONS_SCHOOL;
drop table if exists student;
drop table if exists school;
/*==============================================================*/
/* Table: student */
/*==============================================================*/
create table student
(
StudentID char(10) not null comment '',
SchoolID char(10) not null comment '',
Name char(10) comment '',
primary key (StudentID)
);
/*==============================================================*/
/* Table: school */
/*==============================================================*/
create table school
(
SchoolID char(10) not null comment '',
SchoolName varchar(12) comment '',
primary key (SchoolID)
);
alter table student add constraint FK_STUDENT_RELATIONS_SCHOOL foreign key (SchoolID)
references school (SchoolID) on delete restrict on update restrict;
uj5u.com熱心網友回復:
powerdesigner建模的時候不建立關系匯出來的腳本運行沒問題。 一建立關系就出問題。uj5u.com熱心網友回復:
我現在也遇到了這個問題,而且我知道出錯在哪里。這個生成的SQL里面,alter table **** drop foreign key 在 create table 陳述句之前。
也就是說,在資料表還沒建立的時候,它就試圖洗掉資料表的外鍵。
我嘗試在powerdesigner中尋找設定的方法,但是實在是找不到。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/224647.html
標籤:基礎類
上一篇:Excel連接MySQL資料庫,分不同表匯入powerquery,在進行合并以后上載失敗,報錯
下一篇:互助
