当前位置:网站首页>[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;
边栏推荐
- (原创)制作一个采用 LCD1602 显示的电子钟,在 LCD 上显示当前的时间。显示格式为“时时:分分:秒秒”。设有 4 个功能键k1~k4,功能如下:(1)k1——进入时间修改。
- The latest tank battle 2022 - Notes on the whole development -2
- 甲、乙机之间采用方式 1 双向串行通信,具体要求如下: (1)甲机的 k1 按键可通过串行口控制乙机的 LEDI 点亮、LED2 灭,甲机的 k2 按键控制 乙机的 LED1
- 【Numpy和Pytorch的数据处理】
- 撲克牌遊戲程序——人機對抗
- JS several ways to judge whether an object is an array
- 一段用蜂鸣器编的音乐(成都)
- 7-11 机工士姆斯塔迪奥(PTA程序设计)
- Mode 1 two-way serial communication is adopted between machine a and machine B, and the specific requirements are as follows: (1) the K1 key of machine a can control the ledi of machine B to turn on a
- Mortal immortal cultivation pointer-1
猜你喜欢

Using spacedesk to realize any device in the LAN as a computer expansion screen

Safe driving skills on ice and snow roads

Nuxtjs快速上手(Nuxt2)

It's never too late to start. The tramp transformation programmer has an annual salary of more than 700000 yuan

仿牛客技术博客项目常见问题及解答(一)

强化學習基礎記錄

. How to upload XMIND files to Jinshan document sharing online editing?

UGUI—Text

. Net6: develop modern 3D industrial software based on WPF (2)

1. First knowledge of C language (1)
随机推荐
【头歌educoder数据表中数据的插入、修改和删除】
[the Nine Yang Manual] 2017 Fudan University Applied Statistics real problem + analysis
Difference and understanding between detected and non detected anomalies
5月27日杂谈
Leetcode.3 无重复字符的最长子串——超过100%的解法
Mortal immortal cultivation pointer-1
Strengthen basic learning records
1143_ SiCp learning notes_ Tree recursion
1. Preliminary exercises of C language (1)
Safe driving skills on ice and snow roads
QT meta object qmetaobject indexofslot and other functions to obtain class methods attention
Thoroughly understand LRU algorithm - explain 146 questions in detail and eliminate LRU cache in redis
Redis实现分布式锁原理详解
hashCode()与equals()之间的关系
4. Branch statements and loop statements
Package bedding of components
一段用蜂鸣器编的音乐(成都)
Renforcer les dossiers de base de l'apprentissage
重载和重写的区别
自定义RPC项目——常见问题及详解(注册中心)