1. 创建一个学生班级信息
create databaseschool on primary
(
Name=school_data,
filename='E:\software\exercise\school.mdf',
size=5mb,
maxsize=unlimited,
filegrowth=10%
)
log on
(
Name=school_log,
filename='E:\software\exercise\school.ldf',
size=10mb,
maxsize=unlimited,
filegrowth=2mb
)
2.设置格式
create tablestudents
(学号varchar(3),
姓名varchar(4),
性别varchar(2),
出生年月datetime,
班级varchar(8)
)
3.赋值
insert intostudents(学号,姓名,性别,出生年月,班级)values(01,'李华','男',1993-01-02,0901);
insert intostudents(学号,姓名,性别,出生年月,班级) values (02,'匡明' ,'男' ,1975-10-02,0920);
insert intostudents(学号,姓名,性别,出生年月,班级) values (03,'王丽' ,'女' ,1976-01-23,0903);
insert intostudents(学号,姓名,性别,出生年月,班级) values (04,'李军' ,'男' ,1976-02-20,0902);
insert intostudents(学号,姓名,性别,出生年月,班级) values (05,'王芳' ,'女' ,1975-02-10,0901);
insert intostudents(学号,姓名,性别,出生年月,班级) values (06,'陆君' ,'男' ,1974-06-03,0902);
4.查看数据
select * from students where 班级=902;