if table2 doesn't exist, tryselect name into table2 from table1otherwiseinset into table2 (name) select name from table1>>>>既给table1中的name加入值,table2中的name也相对应地加入相同的值you can add a trigger on table1CREATE TRIGGER trig1
on table1
FOR INSERT
AS
insert into table2 (name) select name from inserted
GO
on table1
FOR INSERT
AS
insert into table2 (name) select name from inserted
GO
on table1
FOR DELETE
AS
delete from table2 where name in (select name from deleted)
GO
aucer(思归, MS .NET MVP) 大侠可是 CSDN 的头号啦!>>>>
对于你的问题,建议你使用 InnoDB 表类型,
由于目前 MySQL 还不支持触发器,
所以你只能使用 InnoDB 的事务处理来安全地实现将数据同时插入两张表而对于第二个问题,
使用 InnoDB 的外键约束就可以啦!!!
If ON DELETE CASCADE is specified, and a row in the parent table is deleted, then InnoDB automatically deletes also all those rows in the child table whose foreign key values are equal to the referenced key value in the parent row.
更详细的请查看这里
http://www.innodb.com/ibman.html#InnoDB_foreign_keys
ON DELETE CASCADE
他们的授权费用怎么交纳的呢?
如果指定了 ON DELETE CASCADE, and a row in the parent table is deleted,
当父表中的一个记录行被删除时
then InnoDB automatically deletes also all those rows in the child table whose foreign key values are equal to the referenced key value in the parent row.
InnoDB 将会自动地子表中外键值与父表中记录行中的引用键值相等的所有记录行
InnoDB 将会自动地删除子表中外键值与父表中记录行中的引用键值相等的所有记录行
:)
嘻嘻,不好意思少了一个词