Auto commit
This commit is contained in:
parent
f2edb6f1f4
commit
d7bb147d7f
37
2207/MySQL数据库操作综合练习题答案.md
Normal file
37
2207/MySQL数据库操作综合练习题答案.md
Normal file
@ -0,0 +1,37 @@
|
||||
### 练习一
|
||||
|
||||
**1**
|
||||
|
||||
```sql
|
||||
#(1)创建数据库
|
||||
CREATE DATABASE test04_Market DEFAULT CHARACTER SET utf8;
|
||||
USE test04_Market;
|
||||
#(2)创建数据表
|
||||
CREATE TABLE customers(
|
||||
c_num INT(11) PRIMARY KEY AUTO_INCREMENT,
|
||||
c_name VARCHAR(50),
|
||||
c_contact VARCHAR(50),
|
||||
c_city VARCHAR(50),
|
||||
c_birth DATETIME NOT NULL
|
||||
);
|
||||
#(3)更改字段的位置
|
||||
#AFTER/BEFORE 字段名 设置位置在指定字段前/后
|
||||
ALTER TABLE 表名 MODIFY 字段名 数据类型 AFTER/BEFORE 字段名;
|
||||
ALTER TABLE customers MODIFY c_contact VARCHAR(50) AFTER c_birth;
|
||||
#(4)更改字段的数据类型
|
||||
ALTER TABLE customers MODIFY c_name VARCHAR(70);
|
||||
#(5)更改字段名
|
||||
ALTER TABLE customers CHANGE c_contact c_phone VARCHAR(50);
|
||||
#(6)添加字段
|
||||
ALTER TABLE customers ADD c_gender CHAR(1);
|
||||
#(7)更改表名
|
||||
ALTER TABLE customers RENAME TO customers_info;
|
||||
#(8)删除字段
|
||||
ALTER TABLE customers_info DROP c_city;
|
||||
```
|
||||
|
||||
**2**
|
||||
|
||||
```sql
|
||||
```
|
||||
|
Loading…
x
Reference in New Issue
Block a user