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; #(建不出来!!!!!)

  • 相关阅读:
    C# List<string>和List<int>互相转换
    sourcetree跳过注册的方法
    列举 contentType: 内容类型(MIME 类型)
    nginx 使用过程中一些基础性问题总结
    MVC3升级到MVC4模型验证信息显示为英文问题及解决方案
    ckeditor:复制内容到ckeditor时,只保留文本,忽略其样式解决方法
    MVC从视图传参到Controller几种方式
    Window Service 计划任务
    Git命令行连Github与TortoiseGit 连Github区别
    For xml path
  • 原文地址:https://www.cnblogs.com/793564949liu/p/11768732.html
Copyright © 2011-2022 走看看