美文网首页
【SQL】17.建立练习数据库test3及表

【SQL】17.建立练习数据库test3及表

作者: 一曈 | 来源:发表于2017-06-07 10:35 被阅读55次
    create table student(
    sno varchar(10) primary key,
    sname varchar(20),
    sage int(2),
    ssex varchar(5)
    );
    create table teacher(
    tno varchar(10) primary key,
    tname varchar(20)
    );
    create table course(
    cno varchar(10),
    cname varchar(20),
    tno varchar(20)
    );
    create table sc(
    sno varchar(10),
    cno varchar(10),
    score decimal(4,2)
    );
    insert into student values ('s001','张三',23,'男');
    insert into student values ('s002','李四',23,'男');
    insert into student values ('s003','吴鹏',25,'男');
    insert into student values ('s004','琴沁',20,'女');
    insert into student values ('s005','王丽',20,'女');
    insert into student values ('s006','李波',21,'男');
    insert into student values ('s007','刘玉',21,'男');
    insert into student values ('s008','萧蓉',21,'女');
    insert into student values ('s009','陈萧晓',23,'女');
    insert into student values ('s010','陈美',22,'女');
    commit;
    insert into teacher values ('t001', '刘阳');
    insert into teacher values ('t002', '谌燕');
    insert into teacher values ('t003', '胡明星');
    commit;
    insert into course values ('c001','J2SE','t002');
    insert into course values ('c002','Java Web','t002');
    insert into course values ('c003','SSH','t001');
    insert into course values ('c004','Oracle','t001');
    insert into course values ('c005','SQL SERVER 2005','t003');
    insert into course values ('c006','C#','t003');
    insert into course values ('c007','JavaScript','t002');
    insert into course values ('c008','DIV+CSS','t001');
    insert into course values ('c009','PHP','t003');
    insert into course values ('c010','EJB3.0','t002');
    commit;
    
    insert into sc values ('s001','c001',78.9);
    insert into sc values ('s002','c001',80.9);
    insert into sc values ('s003','c001',81.9);
    insert into sc values ('s004','c001',60.9);
    insert into sc values ('s001','c002',82.9);
    insert into sc values ('s002','c002',72.9);
    insert into sc values ('s003','c002',81.9);
    insert into sc values ('s001','c003','59');
    commit;
    
    tables course sc student teacher

    相关文章

      网友评论

          本文标题:【SQL】17.建立练习数据库test3及表

          本文链接:https://www.haomeiwen.com/subject/qsyofxtx.html