MySQL通常有这几种约束:
主键 |
默认值 |
唯一 |
外键 |
非空 |
PRIMARY KEY |
DEFAULT |
UNIQUE |
FOREIGN KEY |
NOT NULL |
- 触发器的创建
CREATE TRIGGER trigger_name trigger_time trigger_event
ON tbl_name FOR EACH ROW trigger_stmt
不能同时存在具有相同触发程序动作时间和事件的某个表。如,对于某一个表,不能有两个BEFORE UPDATE触发程序。
trigger_stmt是当触发程序激活时执行的语句。如果执行多个语句,使用BEGIN ... END复合语句结构。
- 触发器的删除
DROP TRIGGER [schema_name.]trigger_name
- 视图的创建
CREATE [OR REPLACE] [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
关于视图处理算法Algorithm,是对标准SQL的MySQL扩展,可以取三个值UNDEFINED | MERGE | TEMPTABLE,若无Algorithm默认是UNDEFINED
- 视图的修改(与create view 相似)
ALTER [ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]
VIEW view_name [(column_list)]
AS select_statement
[WITH [CASCADED | LOCAL] CHECK OPTION]
- 视图的删除
DROP VIEW [IF EXISTS]
view_name [, view_name] ...
来源:https://www.cnblogs.com/lingqinyu/p/8877768.html