SQL对表结构的简单操作

本文介绍了如何使用SQL进行表结构的操作,包括增加表字段、在指定位置插入字段、删除字段、修改字段名和类型以及设置字段默认值。通过这些命令,可以便捷地管理数据库表结构。
摘要由CSDN通过智能技术生成

  • 增加表字段:alter table A add 字段名 字符类型  not null
alter table events add time timestamp not null;
alter table events add id integer not null;
  • 在指定的位置插入表的字段:

 alter table A add 字段名 字符类型 是否为空 after 指定字段

alter events add id integer not null after event_type;
  • 删除表字段: alter table A drop column 字段名
alter table events drop column time;
  • 修改字段名:alter table A rename column a to b
alter table events rename id to id1;
  • 修改字段类型:alter table A alter column 字段名 字符类型 not null
alter table events alter column events_name varchar(50) not null;
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值