第二章MySQL 的基本操作

第二章MySQL 的基本操作

202212046203238 祝文欢  计网2

实验目的:

Mysql 创建 数据库 、数据表、修改数据表


任务一:新建数据库school,使用数据库

create database school;

任务二:新建教师表格(id int comment'工号',name varchar(20) comment'姓名',gender char(1) comment'性别';

create table if not exists teacher(

id int comment'工号',

name varchar(20) comment'姓名',

gender char(1) comment'性别');

任务三:掌握修改数据表的六种方法

  1. 改表名-tch;
alter table teacher rename tch;
  1. 改字段名: id为tchno
alter table tch rename column id to tchno;
  1. 改字段的数据类型:name 为char(20);
alter table tch modify  name char(20);

  1. 添加字段:birthday char(20) comment'生日'  放在name 后面;
       alter table tch  add birthday char(20) comment'生日' after name;

  1. 修改字段的位置:name放第一;
Alter table tch modify name char(20) first;
  1. 删除字段gender;
alter table tch drop gender;

总结归纳:

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值