【mysql】#语法#mysql的删除语法

基本语法


删除数据库

drop database test;

删除表

drop table if exists test; 

删除表数据

DELETE from test /* where id =1 */; #不会减少表或索引所占用的空,可以加where条件,可以进行rollback回滚
TRUNCATE TABLE test; #执行速度快,删除所有的数据,并不把单独的删除操作记录记入日志保存,删除行是不能恢复的,并且在删除的过程中不会触发与表有关的删除触发器

删除表字段

alter table test drop column name; 

删除视图

drop view if exists v_test;

删除函数

drop FUNCTION if exists f_test;

删除存储过程

drop PROCEDURE if exists f_test;

删除触发器

drop TRIGGER if exists f_test;

删除事件

drop EVENT if exists f_test;

猜你喜欢

转载自blog.csdn.net/hj5419/article/details/80352687
今日推荐