码迷,mamicode.com
首页 > 数据库 > 详细

数据库设主键以及where的应用

时间:2015-04-17 19:58:34      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

二、第二课

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=‘五庄观‘

数据库设主键以及where的应用

标签:

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

踩
(0)
赞
(0)
   
举报
评论 一句话评论(0)
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!