数据库设主键以及where的应用
二、第二课
create table teacher
(
tno int primary key identity(1,1), --将tno设为主键(primary key identity(1,1))
tname varchar(50)
)
go
insert into teacher values(‘张三‘)
insert into teacher values(‘李四‘)
insert into teacher values(‘王五‘)
go
select *from teacher
go
delete from teacher where tname=‘王五‘
---查询
select *from player where name=‘约里克‘
--selset *(所有)from 表 where 条件
select *from chinastates where parentareacode=37 and root=1
--and 并且or 或 >= <=
use Player
create table xueshengxinxibiao
(
tno int primary key identity(1,1), --设为主键 primary key identity(1,1) 从1开始,每次递增1
name varchar(50),
sex int,
age int,
cm decimal(18,2),
kg decimal(18,2),
idcard bigint,
addresss varchar(50),
)
insert into xueshengxinxibiao values(‘刘凯‘,1,23,172,65,372328199206190313,‘山东省淄博市张店区‘) --主键字是自动生成的(identity(1,1)),不用自己输入
insert into xueshengxinxibiao values(‘约里克‘,1,23,172,65,372328199206190313,‘山东省淄博市张店区‘)
insert into xueshengxinxibiao values(‘111‘,1,23,172,65,372328199206190313,‘山东省淄博市张店区‘)
insert into xueshengxinxibiao values(‘222‘,1,23,172,65,372328199206190313,‘山东省淄博市张店区‘)
select *from xueshengxinxibiao
update xueshengxinxibiao set name=‘五庄观‘ where tno=3 --把tno=3的这一行改成name=‘五庄观‘
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。