当前位置:网站首页>【educoder数据库实验 索引】
【educoder数据库实验 索引】
2022-07-06 09:22:00 【馥滢( '▿ ' )】
1、任务要求
在sale数据库中,建立供应商数据表
gys,包括供应商号gysh 字符型4位、公司名称 可变长字符型20位、电话 可变长字符型11位、地址 可变长字符型20位、联系人 可变长字符型4位、手机 字符型11位 字段,同时根据供应商号字段建立主索引。
按行的方式显示gyh数据表的索引
use sale;
#代码开始
create table gyh
(
gysh char(4) primary key,
Name varchar(20),
telephone varchar(11),
address varchar(20),
contact varchar(4),
mobile char(11)
);
show index from gyh;
#代码结束
2、任务:
第一题
在xsdmx数据表根据销售单编号xsdh和序号xh两个字段建立主索引xsdxh
第二题
在xsdmx数据表根据商品编号sph字段建立普通索引sphsy。
第三题
在商品sp数据表根据商品名spm字段建立唯一索引spmsy。
use sale
#代码开始
#第一题
alter table xsdmx add primary key(xsdh,xh);
#第二题
create index sphsy on xsdmx(sph);
#第三题
create unique index spmsy on sp(spm);
#代码结束
show index in xsdmx\g;
show index in sp\g;
3、删除sp商品数据表的索引spmsy
删除索引的命令格式
use sale;
#代码开始
alter table sp drop index spmsy;
#代码结束
show index in sp\g;
边栏推荐
- canvas基础1 - 画直线(通俗易懂)
- 实验七 常用类的使用(修正帖)
- 【数据库 三大范式】一看就懂
- Have you encountered ABA problems? Let's talk about the following in detail, how to avoid ABA problems
- [面試時]——我如何講清楚TCP實現可靠傳輸的機制
- [the Nine Yang Manual] 2019 Fudan University Applied Statistics real problem + analysis
- 【九阳神功】2017复旦大学应用统计真题+解析
- Reinforcement learning series (I): basic principles and concepts
- 力扣152题乘数最大子数组
- Wei Pai: the product is applauded, but why is the sales volume still frustrated
猜你喜欢
Redis的两种持久化机制RDB和AOF的原理和优缺点
【手撕代码】单例模式及生产者/消费者模式
4. Binary search
扑克牌游戏程序——人机对抗
【黑马早报】上海市监局回应钟薛高烧不化;麦趣尔承认两批次纯牛奶不合格;微信内测一个手机可注册俩号;度小满回应存款变理财产品...
撲克牌遊戲程序——人機對抗
强化学习系列(一):基本原理和概念
QT meta object qmetaobject indexofslot and other functions to obtain class methods attention
3. Input and output functions (printf, scanf, getchar and putchar)
MySQL锁总结(全面简洁 + 图文详解)
随机推荐
简述xhr -xhr的基本使用
【九阳神功】2019复旦大学应用统计真题+解析
2. Preliminary exercises of C language (2)
受检异常和非受检异常的区别和理解
7-1 输出2到n之间的全部素数(PTA程序设计)
7-14 错误票据(PTA程序设计)
A piece of music composed by buzzer (Chengdu)
【九阳神功】2022复旦大学应用统计真题+解析
[中国近代史] 第五章测验
扑克牌游戏程序——人机对抗
【九阳神功】2017复旦大学应用统计真题+解析
[中国近代史] 第九章测验
【九阳神功】2016复旦大学应用统计真题+解析
MySQL锁总结(全面简洁 + 图文详解)
canvas基础2 - arc - 画弧线
Implementation of count (*) in MySQL
[面試時]——我如何講清楚TCP實現可靠傳輸的機制
[the Nine Yang Manual] 2018 Fudan University Applied Statistics real problem + analysis
FAQs and answers to the imitation Niuke technology blog project (II)
MySQL事务及实现原理全面总结,再也不用担心面试