用 CREATE TABLE 命令建立表的结构

 创建一个水果表fruit
列名分别为:
code (int)
name (varchar(50)) not null
price  (decimal(18,2)) not null
address (varchar(50)) not null
1)查询全部数据
2)查询一列(name)
3)查询多个列(name、产地)
4)根据条件查询一行(code=2)
5)根据条件查找一个数据(code为2的name)
6)根据条件查找多个数据(code为2的name、price)
7)插入一条数据(自己想)
8)更改code为5的水果的价格为8.5
9)删除code为5的水果的数据

use student
go
create table fruit
(
code int,
name varchar(50)not null,
price decimal(18,2) not null,
address varchar (50) not null
)
go
insert into fruit values (1.,'苹果',1.1,'淄博')
insert into fruit values (2.,'梨',1.3,'北京')
insert into fruit values (3.,'香蕉',3.1,'南京')
insert into fruit values (4.,'橘子',2.1,'武汉')
insert into fruit values (5.,'荔枝',3.4,'扬州')
insert into fruit values (6.,'火龙果',2.4,'杭州')
insert into fruit values (7.,'西瓜',2.8,'潍坊')
go

--1)查询全部数据
select * from fruit

--2)查询一列(name)
select name from fruit


--3)查询多个列(name、产地)
select name,address from fruit


--4)根据条件查询一行(code=2)
select*from fruit where code=2


--5)根据条件查找一个数据(code为2的name)
select name from fruit where code=2


--6)根据条件查找多个数据(code为2的name、price)
select name,price from fruit where code=2

--7)插入一条数据(自己想)
insert into fruit values (8.,'芒果',3.6,'浙江')


--8)更改code为5的水果的价格为8.5
update fruit set price=8.5 where code=5


--9)删除code为5的水果的数据
delete from fruit where code=5

转载于:https://www.cnblogs.com/dulovexin/p/4972113.html

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值