csdn作业

#课本P78实验4.2-3
#(2)创建studentinfo表,显示studentinfo表的基本结构 
show databases;
use stuexpm;
desc studentinfo;
show create table studentinfo;
#(3)由studentinfo表使用复制方式创建studentinfo1表
use stuexpm;
create table studentinfo1 like studentinfo;

#(4)在studentinfo1表中增加一列stuno,添加到表的第1列,不为空,取值唯一并自动增加,显示studentinfo表的基本结构
alter table studentinfo1
    add column StuNo int not null unique auto_increment first;
desc studentinfo1;
#(5)将studentinfo1表的address 列修改 为city ,将数据类型改为char,可为空,默认值为"北京",显示studentinfo1表的基本结构
alter table studentinfo1
      change column address city char(20) null default '北京';
desc studentinfo1;
desc studentinfo;
#(6)将studentinfo1表的speciality 列修改为school,将数据类型改为char,可为空,默认值为"计算机学院"
alter table studentinfo1
      change column speciality school char(20) null default '计算机学院';
desc studentinfo1;
#(7)将studentinfo1表的city列的默认值修改为"上海"
alter table studentinfo1
      alter column  city set default '上海';
      desc studentinfo1;
#(8)将studentinfo1表的city列的类型修改为varchar(20),并移到列Name之后
alter table studentinfo1
       modify city varchar(20) after Name;
desc studentinfo1;
#(9)在studentinfo1表中删除stuno列
alter table studentinfo1
    drop column stuno;
#(10)将studentinfo1表更名为studentinfo2表
alter table studentinfo1
    rename to studentinfo2;
#(11)删除studentinfo2表
drop table studentinfo2;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值