0
我有一个teacher_table,其中包含像teacher_name,teacher_age,teacher_phone和teacher_gender这样的少数数据列。如何通过触发器限制表中特定列的更新
我想创建一个触发器查询,限制用户更新我的teacher_table中的teacher_gender列。无论如何要这样做?
我有一个teacher_table,其中包含像teacher_name,teacher_age,teacher_phone和teacher_gender这样的少数数据列。如何通过触发器限制表中特定列的更新
我想创建一个触发器查询,限制用户更新我的teacher_table中的teacher_gender列。无论如何要这样做?
你可以试试这个:
create trigger teacher_gender_check_update
before update on teacher_table
for each row
begin
if (old.teacher_gender IS NOT NULL) then
SIGNAL 'Teacher gender already set'
end if ;
end;
您正在使用什么数据库?触发器以某种程序扩展语言实现,但程序扩展语言对于每个数据库引擎都会有所不同。 SQL Server触发器将与Oracle触发器或MySQL触发器或其他数据库的触发器完全不同。 –
我正在使用sql数据库。 –
SQL是一种语言,而不是数据库。许多数据库的名称中都有“SQL”。例如SQL Server,MySQL和PostgreSQL。你在使用其中之一吗?或者是其他东西? –