mysql08 表结构搭建--练习
搭建的表结构 | 要求说明: |
挑战参考代码
$ sudo service mysql start $ mysql -u root mysql> CREATE DATABASE gradesystem; mysql> use gradesystem mysql> CREATE TABLE student( -> sid int NOT NULL AUTO_INCREMENT, -> sname varchar(20) NOT NULL, -> gender varchar(10) NOT NULL, -> PRIMARY KEY(sid) -> ); mysql> CREATE TABLE course( -> cid int NOT NULL AUTO_INCREMENT, -> cname varchar(20) NOT NULL, -> PRIMARY KEY(cid) -> ); mysql> CREATE TABLE mark( -> mid int NOT NULL AUTO_INCREMENT, -> sid int NOT NULL, -> cid int NOT NULL, -> score int NOT NULL, -> PRIMARY KEY(mid), -> FOREIGN KEY(sid) REFERENCES student(sid), -> FOREIGN KEY(cid) REFERENCES course(cid) -> ); mysql> INSERT INTO student VALUES(1,‘Tom‘,‘male‘),(2,‘Jack‘,‘male‘),(3,‘Rose‘,‘female‘); mysql> INSERT INTO course VALUES(1,‘math‘),(2,‘physics‘),(3,‘chemistry‘); mysql> INSERT INTO mark VALUES(1,1,1,80),(2,2,1,85),(3,3,1,90),(4,1,2,60),(5,2,2,90),(6,3,2,75),(7,1,3,95),(8,2,3,75),(9,3,3,85);
----说明:本材料采用在线实验室,只为了学习记录,无其他用途。
相关推荐
CoderToy 2020-11-16
emmm00 2020-11-17
王艺强 2020-11-17
ribavnu 2020-11-16
bianruifeng 2020-11-16
wangshuangbao 2020-11-13
苏康申 2020-11-13
vivenwan 2020-11-13
moyekongling 2020-11-13
云中舞步 2020-11-12
要啥自行车一把梭 2020-11-12
aydh 2020-11-12
kuwoyinlehe 2020-11-12
minerk 2020-11-12
vitasfly 2020-11-12
jazywoo在路上 2020-11-11
敏敏张 2020-11-11
世樹 2020-11-11