ubuntu上执行SQL语句:alter table 学生 alter 姓名 char(8) not null;
结果出错:you have an error in your SQL syntax;check the manual that corresponds to your Mysql server version for the right syntax to use near 'char(8) not null' at line 1
学生表的创建:
create table 学生
(学号 char(8) primary key,
姓名 char(8),
性别 char(2),
学院代码 char(8),
foreign key(学院代码)references 学院(学院代码));
添加列 alter table 表名 add 列名 列的类型(数据长度) 列的约束
修改列定义 alter table 表名 modify 列名 列的类型(数据长度) 列的约束
修改列定义或名称 alter table 表名 change 旧列名 新列名 列的类型(数据长度) 列的约束
删除列 alter table 表名 drop 列名
修改表的字符集 alter table 表名 character set 字符集
修改数据表名 rename table 旧表名 to 新的表名
ALTER TABLE 旧表名 RENAME 新表名