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

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

时间:2016-06-07 20:47:17      阅读:157      评论:0      收藏:0      [点我收藏+]

标签:

--创建一个名字为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

 

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

标签:

原文地址:http://www.cnblogs.com/fengsantianya/p/5568112.html

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