《信息数据应用实验报告.doc》由会员分享,可在线阅读,更多相关《信息数据应用实验报告.doc(11页珍藏版)》请在金锄头文库上搜索。
1、信息数据应用实验报告实验5数据库查询(I)实验日期2011-10-26学生姓名11学号2010201245数据准备:use master;gocreate database MyDB;goUSE MyDB;gocreate table class(ID char(3) primary key,name nvarchar(10) not null);goinsert into class values(A01,08信管);insert into class values(A02,09信管);insert into class values(A03,10信管);gocreate table stu
2、dent( ID int identity(1,1) not null, sex nchar(1) not null, classID char(3) not null, score int, birthday datetime, constraint zhujian primary key(ID), constraint scorecheck check(score=0 and score=70 and score=0 and score=100);goinsert into student values(王小屁,男,a04,90,1992/02/29);insert into studen
3、t values(王大屁,男,a02,21,1991/05/20);insert into student values(王臭屁,男,a01,59,1990/01/01);insert into student values(唐小尧,男,a03,87,1989/02/28);insert into student values(王屁屁,女,a03,100,1987/12/31);goselect* from student;结果-(1) 修改查询结果的列标题名称select stuID as 学号,stuName as 姓名,score as 成绩from student;结果:select stuID as 学号,stuName as 姓名,score as 成绩,datename(year,birthday)+年+datename(month,birthday)+月+datename(day,birthday)+日as 生日from student;go结果-