当前位置:网站首页>[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;
边栏推荐
- hashCode()与equals()之间的关系
- 7-15 h0161. 求最大公约数和最小公倍数(PTA程序设计)
- ABA问题遇到过吗,详细说以下,如何避免ABA问题
- . How to upload XMIND files to Jinshan document sharing online editing?
- Service ability of Hongmeng harmonyos learning notes to realize cross end communication
- 强化学习系列(一):基本原理和概念
- Differences among fianl, finally, and finalize
- 仿牛客技术博客项目常见问题及解答(三)
- Write a program to simulate the traffic lights in real life.
- [面試時]——我如何講清楚TCP實現可靠傳輸的機制
猜你喜欢

9. Pointer (upper)

附加简化版示例数据库到SqlServer数据库实例中

Mixlab unbounded community white paper officially released

Caching mechanism of leveldb

甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1

canvas基础1 - 画直线(通俗易懂)

Mortal immortal cultivation pointer-1

1143_ SiCp learning notes_ Tree recursion

hashCode()与equals()之间的关系

.Xmind文件如何上传金山文档共享在线编辑?
随机推荐
Analysis of penetration test learning and actual combat stage
FAQs and answers to the imitation Niuke technology blog project (III)
Difference and understanding between detected and non detected anomalies
[during the interview] - how can I explain the mechanism of TCP to achieve reliable transmission
[graduation season · advanced technology Er] goodbye, my student days
5月14日杂谈
MySQL lock summary (comprehensive and concise + graphic explanation)
Reinforcement learning series (I): basic principles and concepts
fianl、finally、finalize三者的区别
1. First knowledge of C language (1)
7-7 7003 组合锁(PTA程序设计)
The latest tank battle 2022 - full development notes-3
Programme de jeu de cartes - confrontation homme - machine
3. Input and output functions (printf, scanf, getchar and putchar)
[modern Chinese history] Chapter V test
7-5 走楼梯升级版(PTA程序设计)
FAQs and answers to the imitation Niuke technology blog project (II)
Nuxtjs快速上手(Nuxt2)
Caching mechanism of leveldb
FAQs and answers to the imitation Niuke technology blog project (I)