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);
    
    
  • 相关阅读:
    shell eval命令
    嘟嘟嘟
    07 linkextractor的基本用法
    rabbitmq消息队列
    5. 哨兵集群
    4.主从同步
    3. redis持久化存储
    2. redis 安全
    1.redis基础
    06. scrapy的Request对象
  • 原文地址:https://www.cnblogs.com/wanyuetian/p/6946009.html
Copyright © 2011-2022 走看看