创建数据库,数据库内部增删改查语句

--创建一个名字为banji0425的数据库
create database banji0425
go
--应用banji0425数据库
use  banji0425
go
--创建一个名字为tongxue的表格
create table tongxue
(
 code int,
 name char(20),
 sex  char(20),
 nianling int,
 fenshu decimal(18,2),
 dizhi   char(20),
)
go
--插入表格内容

insert into tongxue values(1,'刘影','',28,88,'桓台')
go

insert into tongxue values(2,'张德民','',22,88,'沂源')
insert into tongxue values(3,'马志杰','',24,85,'临淄')
insert into tongxue values(4,'马庆鑫','',22,86,'张店')
insert into tongxue values(5,'任东韬','',25,82,'沂源')
insert into tongxue values(6,'高和平','',25,85,'张店')
insert into tongxue values(7,'张玉阁','',24,83,'沂源')
insert into tongxue values(8,'齐鑫','',25,82,'周村')
insert into tongxue values(9,'刘泓瑞','',25,85,'张店')
go

--查询表格所有内容
select *from tongxue
go
--查询name列
select  name from tongxue
go
--查询name与nianling两列的内容
select name,nianling from tongxue
go
--查询行为code3的所有内容
select *from tongxue where code=3
go

--查询fenshu为85的name
select name from tongxue where fenshu=85
go

--修改code=3 fenshu为95
update tongxue set fenshu=95 where code=3
go
select *from tongxue where code=3
go
--查询分数为95并且年龄在24岁的人的名字
select name from tongxue where fenshu=95 and nianling=24
go

 

posted @ 2016-06-07 19:20  枫炎  阅读(300)  评论(0编辑  收藏  举报