数据库查询代码摘要(作业,全是自己做的)
酩王校园
Select stud_id,name
From stud_info
Where birthday>='1.1.1979' and birthday<='1.1.1989'
查询学生的学号和姓名,年龄除了20~30岁的。
select stud_info.stud_id,stud_info.name from stud_info where not exists(select * from stud_grade where stud_info.stud_id=stud_grade.stud_id) 查询没参加考试的学生,学号、姓名。 Select stud_id,name,birthday,gender From stud_info Where birthday>='1.6.1986' and birthday<'1.1.1987' 查询86年下半年出生的学生姓名、年龄、学号、性别。 Select stud_id,name,gender From stud_info Where name like '王%' 查询姓“王”的学生的学号、姓名、性别。 Select * From stud_info Where address like '北京%' 查询地址是家在“北京”的学生的所有信息。 select stud_id,name,birthday,mark from stud_info where birthday<=convert(datetime,' 查询87年以前出生的学生学号、姓名、生日、入学成绩。 select getdate()'Current Date',datepart(month,getdate())as 'Month Number' select avg(grade) from stud_grade where course_id='0401010102' 查询学号为“0401010102”的学生成绩。 Select * From stud_info Where class_name=(Select class_name From stud_info Where name='杨鑫' and stud_id='08010404024') 查询跟我一个班的学生所有的信息。 create database student on primary (name=studten_data, filename='c:\program files\microsoft sql server\mssql\data\student.mdf', size=25, maxsize=100, filegrowth=15%) log on (name=student_log, filename='c:\program files\microsoft sql server\mssql\data\student.ldf', size=10, maxsize=20, filegrowth=2) 新建一个数据库,库名为:学生。 create table stud_info (stud_id char(10) not null, name nvarchar(4) not null, birthday datetime, gender nchar(1), address nvarchar(20), telcode char(12), zipcode char(6), mark decimal(3,0) ) 在数据库中建立一个表,其中第一列为:学号,固定长度为单倍10位数,不允许为空。(可以用default语句定义默认值)第二列为:学生姓名,可变长度为双倍4位数,不允许为空。(每个汉字占用2位字节)第三列为:生日,数据类型为时间精确型。第四列为:学生性别,固定长度为双倍1位数。第五列为:学生地址,可变长度为双倍20位数。第六列为:学生电话,固定长度单倍12位。第七列为:邮政编码,定长单倍6位。第八列为:入学成绩,数据类型是固定精度的3位数字。
文章评论
み中二病患者cccc
...杨鑫 呵,, 大骗子..杨金尧...笑.1
Miss.OK
[ft=,2,][em]e134[/em][/ft]