当前位置:网站首页>[MySQL table structure and integrity constraint modification (Alter)]
[MySQL table structure and integrity constraint modification (Alter)]
2022-07-06 13:53:00 【Fu Ying ('▿')】
database TestDb1 There's a table in it your_table, Please follow the instructions , Add appropriate statements in the code file editing window on the right , Table name your_table Change to my_table.
USE TestDb1;
# Please add the appropriate statement in the space below , Table name your_table Change to my_table:
alter table your_table rename to my_table;Suppose the database MyDb There's a table in it order( Order ) and orderDetail( The order details ) Isometer , The structures of the two tables are as follows: :
order surface
Field name data type remarks orderNo char(12) The order number , Main code orderDate date subscription date customerNo char(12) Customer number , Outer code , And customer.customerNo Corresponding employeeNo char(12) Employee number , Outer code , And employee.employeeNo Corresponding orderDetail surface
Field name data type remarks orderNo char(12) The order number , Main attribute , Outer code , And order.orderNo Corresponding productNo char(12) Product number , Main attribute , Outer code , And product.productNo Corresponding quantityOrdered int Order quantity orderDate date subscription date notes : surface orderDetail The main code of is (orderNo,productNo) form
The task of programming is to orderDetail Table to be modified :
- orderDetail Tabular orderDate The column is obviously redundant , Because every transaction in the same order occurs on the same day , This date is in the order body table order There are records in , Please delete the column orderDate.
- The unit price of the product is the content that needs to be recorded in the order details , Please be there. orderDetail Add columns unitPrice To record the unit price of the product :
Field name data type remarks unitPrice numeric(10,2) The transaction unit price of the product Please follow the instructions , Add appropriate statements in the code file editing window on the right , Realize the above programming tasks .
use MyDb;
# Please add the appropriate SQL Code , Implement programming requirements
# sentence 1: Delete table orderDetail Column in orderDate
alter table orderDetail drop orderDate;
# sentence 2: Add columns unitPrice
alter table orderDetail add column unitPrice numeric(10,2);database MyDb There's a table in it addressBook( Address book ), The structure is as follows :
| Field name | data type | remarks |
|---|---|---|
| serialNo | int | auto number , Main code |
| name | char(32) | full name |
| company | char(32) | Work unit |
| position | char(10) | Position |
| workPhone | char(16) | Office phone |
| mobile | char(11) | mobile phone |
| int | QQ Number | |
| weixin | char(12) | WeChat ID |
The original statement to create the table is as follows :
create table addressBook(serialNo int auto_increment primary key,name char(32),company char(32),position char(10),workPhone char(16),mobile char(11),QQ int,weixin char(12));
Your programming task is to check the table addressBook Make the following modifications :
- take QQ The data type of No. is changed to char(12);
- Will be listed weixin Change it to wechat.
use MyDb; # Please add the appropriate SQL sentence , Implement programming requirements alter table addressBook modify QQ char(12) ; alter table addressBook rename column weixin to wechat;
边栏推荐
- 稻 城 亚 丁
- 强化学习基础记录
- Poker game program - man machine confrontation
- Principles, advantages and disadvantages of two persistence mechanisms RDB and AOF of redis
- [the Nine Yang Manual] 2017 Fudan University Applied Statistics real problem + analysis
- 【头歌educoder数据表中数据的插入、修改和删除】
- [the Nine Yang Manual] 2018 Fudan University Applied Statistics real problem + analysis
- 7-1 输出2到n之间的全部素数(PTA程序设计)
- Service ability of Hongmeng harmonyos learning notes to realize cross end communication
- Beautified table style
猜你喜欢

2022泰迪杯数据挖掘挑战赛C题思路及赛后总结

Meituan dynamic thread pool practice ideas, open source

1. Preliminary exercises of C language (1)

FAQs and answers to the imitation Niuke technology blog project (III)

C language Getting Started Guide

7-7 7003 组合锁(PTA程序设计)

实验六 继承和多态

【手撕代码】单例模式及生产者/消费者模式

1143_ SiCp learning notes_ Tree recursion

Redis的两种持久化机制RDB和AOF的原理和优缺点
随机推荐
7-6 矩阵的局部极小值(PTA程序设计)
渗透测试学习与实战阶段分析
2022 Teddy cup data mining challenge question C idea and post game summary
fianl、finally、finalize三者的区别
Redis实现分布式锁原理详解
实验九 输入输出流(节选)
hashCode()与equals()之间的关系
Canvas foundation 1 - draw a straight line (easy to understand)
甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
js判断对象是否是数组的几种方式
【手撕代码】单例模式及生产者/消费者模式
C language Getting Started Guide
撲克牌遊戲程序——人機對抗
7-9 制作门牌号3.0(PTA程序设计)
透彻理解LRU算法——详解力扣146题及Redis中LRU缓存淘汰
实验七 常用类的使用(修正帖)
【MySQL-表结构与完整性约束的修改(ALTER)】
Strengthen basic learning records
Safe driving skills on ice and snow roads
canvas基础2 - arc - 画弧线