学习SQL的第2章节的心得体会

我对于学习这个章节的主要认识是:学会了如何运用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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值