学习SQL的第2章节的心得体会
2008-12-04 15:18
274 查看
我对于学习这个章节的主要认识是:学会了如何运用sql语句1、创建数据库2、创建数据表3、修改数据库、修改数据表达方式4、删除数据库、删除数据表
创建数据库
create database student
on
(name=student,
filename='E:/学习SQL/HXSql/student.mdf',
size=1
)
log on
(name=student_log,
filename='E:/学习SQL/HXSql/student_log.ldf',
size=1
)
go
use student
create table teachers
(class_name char(8) not null primary key,
dean_name char(8) not null
)
create table students
(stu_id int not null primary key identity(1,1),
stu_name char(8) not null ,
stu_sex bit not null default 1,
stu_age int not null check(stu_age>=0),
stu_class char(8) not null foreign key references teachers(class_name),
stu_address nvarchar(40)
)
select * into stu1 from students
select * from stu
alter table stu
add school varchar(10)
alter table stu1
add primary key (stu_id)
alter table stu
drop column school
alter table stu
alter column stu_name char(10)
drop table stu1
alter table stu
add default'1'for stu_sex
alter table students nocheck constraint FK__students__stu_cl__00551192
alter table stu CONSTRAINT aa check(stuage>=0 and stu_age<=150)
insert into students(stu_name,stu_sex,stu_age,stu_class,stu_address)values('aaa','2','12','aaaa','aaaaaa')
insert into students(stu_name,stu_sex,stu_age,stu_class,stu_address)values('aaa','2','12','aaaa','aaaaaa')
add primary key (stu_id)
drop database students
创建数据库
create database student
on
(name=student,
filename='E:/学习SQL/HXSql/student.mdf',
size=1
)
log on
(name=student_log,
filename='E:/学习SQL/HXSql/student_log.ldf',
size=1
)
go
use student
create table teachers
(class_name char(8) not null primary key,
dean_name char(8) not null
)
create table students
(stu_id int not null primary key identity(1,1),
stu_name char(8) not null ,
stu_sex bit not null default 1,
stu_age int not null check(stu_age>=0),
stu_class char(8) not null foreign key references teachers(class_name),
stu_address nvarchar(40)
)
select * into stu1 from students
select * from stu
alter table stu
add school varchar(10)
alter table stu1
add primary key (stu_id)
alter table stu
drop column school
alter table stu
alter column stu_name char(10)
drop table stu1
alter table stu
add default'1'for stu_sex
alter table students nocheck constraint FK__students__stu_cl__00551192
alter table stu CONSTRAINT aa check(stuage>=0 and stu_age<=150)
insert into students(stu_name,stu_sex,stu_age,stu_class,stu_address)values('aaa','2','12','aaaa','aaaaaa')
insert into students(stu_name,stu_sex,stu_age,stu_class,stu_address)values('aaa','2','12','aaaa','aaaaaa')
add primary key (stu_id)
drop database students
相关文章推荐
- 学习SQL的一些心得体会!
- 学习SQL的心得体会之三
- IIS 6.0学习心得体会(二)--实践篇
- [转]Flash与Flex3结合学习心得体会_Rich.Lee的网路历程_百度空间(转载)
- 师德师风学习心得体会
- 黑马程序员—1—Java基础:环境变量学习笔记和心得体会
- 我学习Javascript的心得体会与Javascript的小总结
- 学习java并发编程实战的一些心得体会(一)
- Echarts的使用和学习心得体会(二)
- sql 数字转化 学习心得。
- 学习java心得体会(一)
- 学习Struct框架是遇到的问题及心得体会
- PHP框架Laravel学习心得体会
- Linux内核分析课程8周学习的心得体会
- 关于OR-Mapping的学习心得体会
- 新概念英语学习心得体会
- 个人学习Java的心得体会
- 学习matlab的一点心得体会
- GO语言高并发学习心得体会
- 学习心得体会