sql server insert&nbsp…

本文通过具体实例介绍了SQL的基本操作,包括插入、删除、更新和查询等常用命令。还展示了如何使用SQL进行表结构的修改,例如增加和删除字段、设置主键及外键约束等。
insert into 表名(字段,字段...) values (value1,value2...)-----

delete from 表名 where stuSex = '男' and stuTel like '18%'---删除性别为男且号码是18开头的

update 表名 set stuBirthday = '1996.09.04' where stuName = '张三'
在名字为 张三 处插入生日

select stuName from 表名 where styID = '14046129'-----查询ID为14046129的学生的姓名

----以下是上课敲的代码------------------------------------------

Alter table information
drop FK__informati__stuID__0EA330E9
Alter table Student --删除了身为主键的约束和身为外键的约束
drop PK__Student__AEC9BFAF7F60ED59

Alter table Student --删除了主键
drop column stuID

Alter table Student
add  StuID char(8) primary key --增加了主键,并且修改了类型

Alter table information
alter column StuID char(8) --修改字段类型

Alter table information
add constraint fk_stuID_student --增加约束外键()关联到()
foreign key(stuID) references Student(stuID) 

insert into Student
(StuID,stuName,stuSex,stuTel,stuPosition) --插入指定字段的指定值
values
('14046015','赵建波','男','18383930457','班长'),
('14040023','吴华敏','女','15272638495','宣传委员'),
('14046129','郭浩','男','18283933002','部门主管')


delete from student where stuSex ='男' and stuTel like '18%' --删除男生,且号码是18 开头的

select * from student --查询表student

select * from student where stuTel like '15%' --查询号码是15开头的

select stuName from student where stuTel like ('18%') --查询号码是18开头的人名是什么

关于 update 参考------> update
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值