创建和删除数据库;                                                        。数据库和表的基本操作

创建数据表,查看数据表

数据库和表的基本操作

修改数据表

修改表名: alter table 旧表名 rename to 新表名

数据库和表的基本操作

修改字段名: alter table 表名  change  旧字段名 新字段名 新数据类型

数据库和表的基本操作

修改字段数据类型 :alter table 表名 modify 字段名 数据类型

数据库和表的基本操作

添加字段 :alter table 表名 add 新字段名 数据类型 [约束条件] [firist|after 已存在字段名]

数据库和表的基本操作

删除字段:alter table 表名 drop 字段名

数据库和表的基本操作

修改字段的排列位置:alter table 表名 modify  字段1 数据类型  first|after 字段

数据库和表的基本操作

源代码在下:

create database student;
use student;
create table grade(
name varchar(12),
id int(4),
adress varchar(12)
);
alter table grade rename stu ;
alter table stu change name username varchar(8);
alter table stu modify username varchar(12);
alter table stu add sex char(4) after username;  
alter table stu drop username;
alter table stu modify adress varchar(12) frist;

 

相关文章: