资源描述:
《MySQL试题-测试、复习、查看》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、设计三张表创建student表(学生表)Createtablestudent(Sidtinyintprimarykeyauto_increment,namechar(10),Sexchar(5),Sagetinyint,Sdeptchar(20));insertintostudent(Sid,Sname,Sex,Sage,Sdept)values(l,‘张三'/女',20,'IT');insertintostudent(Sid,Sname,Sex,Sage,Sdept)values(2/李四,,'女',25/info');insertintostudent
2、(Sid,Snam巳Sex’Sag巳Sdept)values(3,王五丁男n');insertintostudent(SidzSname,Sex,Sage/Sdept)values(4/马云T女',28,'ch');insertintostudent(Sid,Sname/Sex,Sage/Sdept)values(5/赵子龙',女18Zinfo');insertintostudent(Sid,Sname,Sex,Sage,Sdept)values伍/王小T女',21/info');insertintostudent(Sid,Sname,Sex,Sage,
3、Sdept)values(7,'赵龙龙男',24,'en*);创建course表(课程表)Createtablecourse(Cidtinyintprimarykeyauto_increment,Cnamechar(20),Ccredittinyint);insertintocoursevalues(l,'数据结构:5);insertintocoursevalues(2,'数据库',10);insertintocoursevalues(3,英语:3);insertintocoursevalues(4,数学:6);创建sc表(选课表)createtables
4、c(Sidtinyint,Cidint,Gradeint);insertintoscvalues(l,l/65);insertintoscvalues(l,2,60);insertintoscvalues(l,4,90);insertintoscvalues(l,3,50);insertintoscvalues(2,2,100);insertintoscvalues(3,l,90);insertintoscvalues(6,2,70);insertintoscvalues(4,4,90);insertintoscvalues(5,1,95);inserti
5、ntoscvalues(6,l,80);insertintoscvalues(7,3,80);仓ij建admin表createtableadmin(idint(10),qqint(20),uidint⑸);创建province表createtableprovince(idint(10)primarykeyauto_increment,pnamevarchar(30));insertintoprovince(id,pname)values(2/JbW);insertintoprovince(id,pname)values(3,广州');insertintop
6、rovince(id,pname)values(4,成都J;创建student2表createtablestudent2(idint(10)primarykeyauto」ncrement’namevarchar(30),pidint(10),foreignkey(pid)referencesprovince(id)ondeletecascade);正则查询建表创建表user两个字段一个id—个nameCreatetableuser(idint(10),namevarchar(20));Insertintouser(name)values(,bat,)/(,
7、baet,)/('baaset,),(,atath')/('astst,);创建一个表,两个字段,商品名称,商品价格Createtablegoodsfidint(10)primarykey,goodsNamevarchar(20),priceint(20));InsertintogoodsValuesfl/HuaWei^lOOO);InsertintogoodsValues(2/Vivo*/1500);InsertintogoodsValues(3,Iphone',3000);InsertintogoodsValues(4,honor:600);Inser
8、tintogoodsValues(5/HuaWei2'z2000)