2020-10-31

这篇博客展示了如何创建和使用SQL数据库,包括创建sale数据库、定义数据文件和日志文件的大小,以及创建customer、entry和product表。接着,填充了各表的数据,并进行了查询、数据过滤和更新操作。博客还涉及到了数据的插入、查询和修改,体现了数据库管理和数据操作的基本流程。
摘要由CSDN通过智能技术生成

–1.创建一个数据库sale
–主数据文件容量为4MB,事务日志文件容量为10MB,
–数据文件和日志文件的最大容量为20MB,文件增量为1MB
create database saleon
(name = sale,
filename = ‘C:\Users\admin\Desktop\sale.mdf’,
size = 4,
maxsize = 20,
filegrowth = 1)
log on
(name = sale_log,
filename = ‘C:\Users\admin\Desktop\sale_log.ldf’,
size = 10,
maxsize = 20,
filegrowth = 1)
–2.使用数据库
use sale
–创建客户信息表customer
create table customer
(cusno nvarchar(20) not null,
cusname nvarchar(10) not null,
cusaddress nvarchar(30) null,
cusphone int null)
–创建入库信息entry
create table entry(eno nvarchar(20) not null,
inputdata datetime not null,
amount decimal(6,0) not null --数量)

–创建一个产品表product
create table product
(pno nvarchar(20) not null,
pname nvarchar(20) not null,
pprice decimal(8,2) not null,
–价格pstocks decimal(8,0) not null --库存量)
–创建customer表中的数据内容insert into customer
select 1001,‘杨洋’,‘北京’,0233-11119999 union
select 1002,‘拟好’,‘深圳’,0233-11118888 union
select 1003,‘张三’,‘河南’,0233-22221111 union
select 1004,‘李四’,‘湖南’,0233-33338888 union
select 1004,‘李四’,‘湖南’,0233-33338888 union
select 1005,‘小明’,‘河北’,0233-77772222
–查询customer表中所有的数据
select all*from customer
–过滤掉重复的数据
select distinct *from customer
–获取前3行的数据
select top 3 *from customer
–获取前百分30的百分比
select top 30 percent *from customer
–修改列中的内容update customer set cusname = ‘古斯’ where cusname = ‘张三’
–创建entry表中的数据内容insert into entry
select 1001-01-01,00001,10
select 1001-01-02,00002,7 union
select 1001-01-03,00001,5 union
select 1001-01-04,00001,9 union
select 1001-02-01,00003,30 union
select 1001-02-02,00004,30 union
select 1001-02-02,00005,10 union
select 1001-02-02,00007,40
–创建并完善product表中的信息insert into product
select 00001,‘电视’,3000.00,800 union
select 00002,‘洗衣机’,5000.00,800 union
select 00003,‘床’,700.00,900 union
select 00004,‘空调’,9000.00,500 union
select 00005,‘沙发’,3500.00,600 union
select 00006,‘餐桌’,300.00,800
–查询product表
select pno as 物品号,pname as 物品,pprice as 物品价格,pstocks as 库存货量 from product

1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博私信或留言,博看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看rEADME.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博删除。 6、可私信博看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博私信或留言,博看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看rEADME.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博删除。 6、可私信博看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博私信或留言,博看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博删除。 6、可私信博看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值