资源描述:
《MySQL试题-测试、复习、查看.doc》由会员上传分享,免费在线阅读,更多相关内容在行业资料-天天文库。
1、设计三张表创建student表(学生表)Createtablestudent(Sidtinyintprimarykeyauto_increment,Snamechar(10),Sexchar(5),Sagetinyint,Sdeptchar(20));insertintostudent(Sid,Sname,Sex,Sage,Sdept)values(1,'张三','女',20,'IT');insertintostudent(Sid,Sname,Sex,Sage,Sdept)values(2,'李四','女',25,'info');insertintostudent(Sid,Sna
2、me,Sex,Sage,Sdept)values(3,'王五','男',22,'en');insertintostudent(Sid,Sname,Sex,Sage,Sdept)values(4,'马云','女',28,'ch');insertintostudent(Sid,Sname,Sex,Sage,Sdept)values(5,'赵子龙','女',18,'info');insertintostudent(Sid,Sname,Sex,Sage,Sdept)values(6,'王小','女',21,'info');insertintostudent(Sid,Sname,Sex,S
3、age,Sdept)values(7,'赵龙龙','男',24,'en');创建course表(课程表)Createtablecourse(Cidtinyintprimarykeyauto_increment,Cnamechar(20),Ccredittinyint);insertintocoursevalues(1,'数据结构',5);insertintocoursevalues(2,'数据库',10);insertintocoursevalues(3,'英语',3);insertintocoursevalues(4,'数学',6);创建sc表(选课表)createtables
4、c(Sidtinyint,Cidint,Gradeint);insertintoscvalues(1,1,65);insertintoscvalues(1,2,60);insertintoscvalues(1,4,90);insertintoscvalues(1,3,50);insertintoscvalues(2,2,100);insertintoscvalues(3,1,90);insertintoscvalues(6,2,70);insertintoscvalues(4,4,90);insertintoscvalues(5,1,95);insertintoscvalues(
5、6,1,80);insertintoscvalues(7,3,80);创建admin表createtableadmin(idint(10),qqint(20),uidint(5));创建province表createtableprovince(idint(10)primarykeyauto_increment,pnamevarchar(30));insertintoprovince(id,pname)values(2,'上海');insertintoprovince(id,pname)values(3,'广州');insertintoprovince(id,pname)value
6、s(4,'成都');创建student2表createtablestudent2(idint(10)primarykeyauto_increment,namevarchar(30),pidint(10),foreignkey(pid)referencesprovince(id)ondeletecascade);正则查询建表创建表user两个字段一个id一个nameCreatetableuser(idint(10),namevarchar(20));Insertintouser(name)values('bat'),('baet'),('baaset'),('atath'),('a
7、stst');创建一个表,两个字段,商品名称,商品价格Createtablegoods(idint(10)primarykey,goodsNamevarchar(20),priceint(20));InsertintogoodsValues(1,'HuaWei',1000);InsertintogoodsValues(2,'Vivo',1500);InsertintogoodsValues(3,'iphone',3000);InsertintogoodsValues(4,'hon