Demo entry 6687636

sql

   

Submitted by anonymous on Dec 30, 2017 at 04:32
Language: MySQL. Code size: 7.4 kB.

CREATE DATABASE `STC` DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci;

USE `STC`;

CREATE TABLE IF NOT EXISTS `student` (
  `Sno` INT (11) NOT NULL,
  `Sname` VARCHAR (510) NOT NULL,
  `Ssex` VARCHAR (10) NOT NULL,
  `Sage` INT (11) DEFAULT NULL,
  `Sdept` VARCHAR (10) DEFAULT NULL,
  PRIMARY KEY (`Sno`)
) ENGINE = INNODB DEFAULT CHARSET = utf8 CREATE TABLE IF NOT EXISTS `course` (
  `Cno` INT (11) NOT NULL,
  `Cname` VARCHAR (10) NOT NULL,
  `Cpno` INT (11) DEFAULT NULL,
  `Ccredit` INT (11) DEFAULT NULL,
  PRIMARY KEY (`Cno`)
) ENGINE = INNODB DEFAULT CHARSET = utf8 CREATE TABLE IF NOT EXISTS `sc` (
  `Sno` INT (11) NOT NULL,
  `Cno` INT (11) NOT NULL,
  `Grade` INT (11) DEFAULT NULL,
  PRIMARY KEY (`Sno`, `Cno`),
  CONSTRAINT `sc_ibfk_1` FOREIGN KEY (`Sno`) REFERENCES `student` (`Sno`),
  CONSTRAINT `sc_ibfk_2` FOREIGN KEY (`Cno`) REFERENCES `course` (`Cno`)
) ENGINE = INNODB DEFAULT CHARSET = utf8
INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515001,
    '赵菁菁',
    '女',
    23,
    'CS'
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515002, '李勇', '男', 20, 'CS');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515003, '张力', '男', 19, 'CS');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515004, '张衡', '男', 18, 'IS');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515005,
    '张向东',
    '男',
    20,
    'IS'
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515006,
    '张向丽',
    '女',
    20,
    'IS'
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515007, '王芳', '女', 20, 'CS');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515008,
    '王民生',
    '男',
    25,
    'MA'
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515009,
    '王小民',
    '女',
    18,
    'MA'
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515010, '李晨', '女', 22, 'MA');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515011, '张毅', '男', 20, 'WM');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515012, '杨磊', '女', 20, 'EN');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515013, '李晨', '女', 19, 'MA');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515014,
    '张丰毅',
    '男',
    22,
    'CS'
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515015, '李蕾', '女', 21, 'EN');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515016, '刘社', '男', 21, 'CM');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515017,
    '刘星耀',
    '男',
    18,
    'CM'
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515018, '李贵', '男', 19, 'EN');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515019,
    '林自许',
    '男',
    20,
    'WM'
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515020, '马翔', '男', 21, NULL);

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515021, '刘峰', '男', 25, 'CS');

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515022,
    '牛站强',
    '男',
    22,
    NULL
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515023,
    '李婷婷',
    '女',
    18,
    NULL
  );

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (200515024, '严丽', '女', 20, NULL);

INSERT INTO `student` (
  `Sno`,
  `Sname`,
  `Ssex`,
  `Sage`,
  `Sdept`
)
VALUES
  (
    200515025,
    '朱小鸥',
    '女',
    30,
    'WM'
  );

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (1, '数据库', 5, 4);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (2, '数学', NULL, 2);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (3, '信息系统', 1, 4);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (4, '操作系统', 6, 3);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (5, '数据结构', 7, 4);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (6, '数据处理', NULL, 2);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (7, 'PASCAL语言', 6, 4);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (8, '大学英语', NULL, 4);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (9, '计算机网络', NULL, 4);

INSERT `course` (`Cno`, `Cname`, `Cpno`, `Ccredit`)
VALUES
  (10, '人工智能', NULL, 2);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515001, 1, 75);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515002, 1, 85);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515002, 3, 53);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515003, 1, 86);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515004, 1, 74);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515005, 1, 58);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515006, 1, 84);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515004, 2, 46);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515005, 2, 89);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515006, 2, 65);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515008, 2, 72);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515009, 2, 76);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515010, 2, 96);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515010, 8, 86);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515011, 8, 62);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515015, 8, 0);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515018, 8, 58);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515001, 4, 62);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515002, 4, 85);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515021, 9, 54);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515001, 5, 58);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515021, 6, 58);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515001, 7, 70);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515005, 10, 65);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515016, 8, NULL);

INSERT INTO `sc` (`Sno`, `Cno`, `Grade`)
VALUES
  (200515017, 8, NULL);

This snippet took 0.02 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).