#1.添加字段 ALTER TABLE student ADD stuAge INT NOT NULL; #2.修改字段 ALTER TABLE student CHANGE stuAge sAge VARCHAR (100)NOT NULL; #3.修改表名 ALTER TABLE students RENAME student; #4.删除字段 ALTER TABLE student DROP sAge; #1.添加唯一约束 ALTER TABLE grade ADD CONSTRAINT stuName UNIQUE KEY(stuName); #2.删除唯一约束 ALTER TABLE grade DROP INDEX stuName; #1.添加默认值约束 (地址默认北京) ALTER TABLE student ALTER COLUMN stuAddress SET DEFAULT '北京' #2.删除默认值约束 ALTER TABLE student ALTER COLUMN stuAddress DROP DEFAULT #1.给student表中添加一个stuAge的字段 ALTER TABLE student ADD stuAge INT #2.给stuAge添加一个检查约束,验证是否可以成功 ALTER TABLE student ADD CONSTRAINT ck_stuAge CHECK (stuAge>=18) #3.验证stuAge字段的检查约束是否成功 INSERT INTO student(stuName,stuGradeid,stuAge) VALUES("陈七",1,17) #4.删除检查约束是不成功的 ALTER TABLE student DROP CONSTRAINT ck_stuAge #1.删除外键约束 ALTER TABLE student2 DROP FOREIGN KEY FK_Grade_Student_GradeId # ALTER TABLE student2 ADD CONSTRAINT FK_Grade_Student_GradeId FOREIGN KEY (stuGradeid) REFERENCES `grade`(gid)