zoukankan      html  css  js  c++  java
  • 1030 作业

    1.MySQL -u root -p
    2.输入密码
    3.show databases; #(查看库)
    4.没有就创建
    5.create database school charset utf8; #(创建学校库)
    6.use school; #(进学校库)
    7.show tables; #(查看表)
    8.没有就创建
    9.create table class(cid int unsigned auto_increment primary key,caption char(32) not null default '')charset utf8; #(创建班级表)
    10.desc class; #(查看班级表结构)
    11.insert into class (cid,caption) values (1,'三年二班'); #(在班级表里添加数据)
    12.select * from class; #(查看班级表数据)
    13.create table teacher(tid int unsigned auto_increment primary key,tname char(32) not null default '')charset utf8; #(创建老师表)
    14.insert into teacher(tname) values ('瑞兹'),('悠米'),('菲欧娜'); #(老师表添加数据)
    15.select * from teacher; #(查看老师表数据)
    16.create table student(sid int unsigned auto_increment primary key,sname varchar(32) not null default '',gender varchar(32) not null default '',class_id int unsigned ,constraint fk_class_student foreign key (class_id) references class (cid))charset utf8; #(创建学生表,关联班级表)
    17.insert into student (sname,gender,class_id) values ('盖伦','男',1),('赵信','男',2),('卡特琳娜','女',3); #(学生表添加数据)
    18.create table course(cid int unsigned auto_increment primary key,cname varchar(32) not null default '',teacher_id int unsigned,constraint fk_teacher_course foreign key (teacher_id) references teacher (tid))charset utf8; #(创建课程表,关联老师表)
    19.insert into course (cname,teacher_id) values ('魔法',1),('策略',2),('技巧',3); #(课程表添加数据)
    20.create table score(
    sid int unsigned auto_increment primary key,
    student_id int not null default 1,
    course_id int not null default 1,
    number int unsigned auto_increment primary key,
    constraint fk_student_score foreign key (student_id) references student(sid),
    constraint fk_course_score foreign key (course_id) references course(cid)
    )charset utf8;
    20.create table score(sid int unsigned auto_increment primary key,student_id int not null default 1,course_id int not null default 1,number int unsigned auto_increment primary key,constraint fk_student_score foreign key (student_id) references student(sid),constraint fk_course_score foreign key (course_id) references course(cid))charset utf8; #(建不出来!!!!!)

  • 相关阅读:
    2015年新的征程,我的博客开通啦!
    基于USB3.0、DP1.2的网络隔离数据安全传输方案
    USB OTG to PC USB API简介
    SMA2SATA、PCIe2SATA转换模块(也有叫:Sata Test Fixtures)
    SATA接口硬盘加密器
    SVN二次开发——让SVN、TSVN(TortoiseSVN)支持windows的访问控制模型、NTFS ADS(可选数据流、NTFS的安全属性)
    About USB Data Link Cable API
    蓝牙4.0BLE抓包(三) – 扫描请求和扫描响应
    nRF51822外设应用[2]:GPIOTE的应用-按键检测
    蓝牙4.0BLE抓包(二) – 广播包解析
  • 原文地址:https://www.cnblogs.com/793564949liu/p/11768732.html
Copyright © 2011-2022 走看看