数据库设主键以及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='五庄观'

原文地址:https://www.cnblogs.com/lk-kk/p/4435728.html