首页 > 数据库技术 > 详细

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

时间:2015-04-17 19:56:18      阅读:293      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!