CREATE TABLE `project` (
`prj_id` int(11) NOT NULL AUTO_INCREMENT,
`prj_name` varchar(400) NOT NULL,
`prj_customer_id` int(11) NOT NULL,
`prj_url` varchar(400) NOT NULL,
`prj_description` varchar(400) NOT NULL,
`prj_status` int(11) NOT NULL,
`prj_member_id` int(11) NOT NULL,
`prj_crtd_by` varchar(50) NOT NULL,
`prj_crtd_dt` datetime NOT NULL,
`prj_updt_by` varchar(50) NOT NULL,
`prj_updt_dt` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
`prj_last_ip` varchar(50) NOT NULL,
PRIMARY KEY (`prj_id`),
KEY `fk_project_customer_customer_id` (`prj_customer_id`),
KEY `fk_project_member_member_id` (`prj_member_id`),
CONSTRAINT `fk_project_customer_customer_id` FOREIGN KEY (`prj_customer_id`) REFERENCES `customer` (`cus_id`),
CONSTRAINT `fk_project_member_member_id` FOREIGN KEY (`prj_member_id`) REFERENCES `member` (`mem_id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
我想爲這個表項目創建三個列的觸發器。我想爲prj_crtd_dt
創建觸發器,這些列創建時插入日期,prj_updt_dt
插入更新日期,prj_last_ip
必須更新創建系統的IP地址。創建一個觸發器獲取客戶端IP地址到MySQL列中
我創建觸發器的日期欄,我想知道如何創建一個IP地址 CREATE TRIGGER create_date_of_customer BEFORE INSERT ON customer FOR EACH ROW SET NEW.cus_crtd_dt = NOW(); NEW.cus_updt_dt = NOW();
稍微更具可讀性。 – filiprem