zoukankan      html  css  js  c++  java
  • Python全栈之路-MySQL(二)

    MySQL实践

    create table class (              
    cid int not null auto_increment primary key,              
    caption char(20) not null
    )engine=innodb default charset=utf8;
    
    
    create table student (              
    sid int not null auto_increment primary key,              
    sname char(20) not null,
    gender char(1) not null,
    class_id int not null,
    constraint fk_student_class foreign key (class_id) references class(cid)
    )engine=innodb default charset=utf8;
    
    create table teacher (              
    tid int not null auto_increment primary key,              
    tname char(20) not null
    )engine=innodb default charset=utf8;
    
    create table course (              
    cid int not null auto_increment primary key,              
    cname char(20) not null,
    teacher_id int not null,
    constraint fk_course_teacher foreign key (teacher_id) references teacher(tid)
    )engine=innodb default charset=utf8;
    
    create table score (              
    sid int not null auto_increment primary key,              
    student_id int not null,
    course_id int not null,
    number int not null,
    constraint fk_score_student foreign key (student_id) references student(sid),
    constraint fk_score_course foreign key (course_id) references course(cid)
    )engine=innodb default charset=utf8;
    
    
    
    
    insert into class(caption) values('三年二班'),('一年三班'),('三年一班');
    
    insert into student(sname,gender,class_id) values('钢蛋','女',1),('铁锤','铁锤',1),('山炮','男',2);
    
    
    insert into teacher(tname) values('波多'),('苍空'),('饭岛');
    
    insert into course(cname,teacher_id) values('生物',1),('体育',1),('物理',2);
    
    insert into score(student_id,course_id,number) values(1,1,60),(1,2,59),(2,2,100);
    
    
  • 相关阅读:
    nvm安装及使用(windon/mac)
    JVM学习笔记
    Java多线程
    OkHttpClient调优案例
    Java各版本新增特性, Since Java 8
    Linux下MySQL数据库的备份与恢复
    算法和数据结构学习笔记
    联想台式机安装网卡驱动指南
    解决「现有新的ios更新可用,请从ios14 beta 版更新」问题
    linux 命令英文全称(转帖)
  • 原文地址:https://www.cnblogs.com/wanyuetian/p/6946009.html
Copyright © 2011-2022 走看看