当前位置:网站首页>[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;
边栏推荐
- 甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
- 【MySQL-表结构与完整性约束的修改(ALTER)】
- [面试时]——我如何讲清楚TCP实现可靠传输的机制
- 1. Preliminary exercises of C language (1)
- C language Getting Started Guide
- Renforcer les dossiers de base de l'apprentissage
- 3. C language uses algebraic cofactor to calculate determinant
- Mixlab unbounded community white paper officially released
- FAQs and answers to the imitation Niuke technology blog project (I)
- [the Nine Yang Manual] 2017 Fudan University Applied Statistics real problem + analysis
猜你喜欢
canvas基础1 - 画直线(通俗易懂)
FAQs and answers to the imitation Niuke technology blog project (III)
Caching mechanism of leveldb
强化学习基础记录
受检异常和非受检异常的区别和理解
(original) make an electronic clock with LCD1602 display to display the current time on the LCD. The display format is "hour: minute: Second: second". There are four function keys K1 ~ K4, and the fun
【VMware异常问题】问题分析&解决办法
Poker game program - man machine confrontation
8. C language - bit operator and displacement operator
MATLAB打开.m文件乱码解决办法
随机推荐
[modern Chinese history] Chapter 6 test
简单理解ES6的Promise
优先队列PriorityQueue (大根堆/小根堆/TopK问题)
2022 Teddy cup data mining challenge question C idea and post game summary
3. C language uses algebraic cofactor to calculate determinant
The difference between overloading and rewriting
Miscellaneous talk on May 14
Yugu p1012 spelling +p1019 word Solitaire (string)
MySQL中count(*)的实现方式
It's never too late to start. The tramp transformation programmer has an annual salary of more than 700000 yuan
使用Spacedesk实现局域网内任意设备作为电脑拓展屏
Nuxtjs quick start (nuxt2)
[hand tearing code] single case mode and producer / consumer mode
Intensive literature reading series (I): Courier routing and assignment for food delivery service using reinforcement learning
The difference between cookies and sessions
7-4 散列表查找(PTA程序设计)
强化学习基础记录
String ABC = new string ("ABC"), how many objects are created
Brief introduction to XHR - basic use of XHR
【九阳神功】2017复旦大学应用统计真题+解析