[英]database phpmyadmin on insert trigger
Have this SQL. 有这个SQL。
CREATE TABLE `accounts` (
`account_id` int(3) NOT NULL,
`username` varchar(36) NOT NULL,
`password` varchar(36) NOT NULL,
`email` varchar(60) NOT NULL,
`access_level` int(1) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
CREATE TABLE `normal_profile` (
`normal_profileid` int(11) NOT NULL,
`first_name` varchar(64) NOT NULL,
`middle_name` varchar(64) NOT NULL,
`last_name` varchar(64) NOT NULL,
`age` int(2) NOT NULL,
`gender` varchar(6) NOT NULL,
`account_id` int(3) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
ALTER TABLE `normal_profile`
ADD CONSTRAINT `normal_profile_ibfk_1` FOREIGN KEY (`account_id`) REFERENCES `accounts` (`account_id`);
The above is how i set constraints. 以上是我如何设置约束。
Whenever i insert something on to my accounts table, do i also have to query an insert into the normal_profile table? 每当我在我的帐户表上插入一些内容时,我是否还必须在normal_profile表中查询插入内容? or can i automatically make it so that the DB itself will just add a row into normal_profile where account_id = accounts.account_id?
或者我可以自动创建它以便数据库本身只会在normal_profile中添加一行,其中account_id = accounts.account_id?
I have a vague memory of an on insert constraint or maybe im mistaken? 我对插入约束有一个模糊的记忆,或者我错了?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.