sql 表结构操作

以下以student表为例

--查看表结构

desc student;

--添加字段
alter table student add (字段名)age (数据类型)int unsigned (约束)not null default 0;
alter table student add birthday datetime; --birthday 字段名 datetime数据类型,约束


--更改字段数据类型,约束
alter table student modify (字段名)birthday (约束)date;


--更改字段名
--alter table student change (原名)birthday (重命名)birth (数据类型,约束)datetime default "0-0-0-0";
alter table student change birthday birth datetime default "0-0-0-0";


--删除字段 (慎用)
alter table student drop age;

原文地址:https://www.cnblogs.com/jum-bolg/p/11222760.html