PowerDesigner中PDM导出的SQL语句

/*==============================================================*/
/* DBMS name:      MySQL 5.0                                    */
/* Created on:     2014/11/23 2:03:17                           */
/*==============================================================*/


drop table if exists Class;

drop table if exists Course;

drop table if exists Student;

drop table if exists 选课;

/*==============================================================*/
/* Table: Class                                                 */
/*==============================================================*/
create table Class
(
   班级号                  char(4) not null,
   Sno                  char(12),
   班级名                  varchar(20),
   primary key (班级号)
);

/*==============================================================*/
/* Table: Course                                                */
/*==============================================================*/
create table Course
(
   Cno                  char(4) not null,
   Cname                char(10),
   Ccredit              int,
   Cpno                 char(4),
   primary key (Cno)
);

/*==============================================================*/
/* Table: Student                                               */
/*==============================================================*/
create table Student
(
   Sno                  char(12) not null,
   班级号                  char(4),
   Sname                varchar(10) not null,
   Ssex                 char(2),
   Sage                 int,
   primary key (Sno)
);

/*==============================================================*/
/* Table: 选课                                                    */
/*==============================================================*/
create table 选课
(
   Cno                  char(4) not null,
   Sno                  char(12) not null,
   成绩                   int,
   primary key (Cno, Sno)
);

alter table Class add constraint FK_任班长 foreign key (Sno)
      references Student (Sno) on delete restrict on update restrict;

alter table Student add constraint FK_属于 foreign key (班级号)
      references Class (班级号) on delete restrict on update restrict;

alter table 选课 add constraint FK_选课 foreign key (Cno)
      references Course (Cno) on delete restrict on update restrict;

alter table 选课 add constraint FK_选课2 foreign key (Sno)
      references Student (Sno) on delete restrict on update restrict;


 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值