By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
CREATE TABLE Sotrudnik (
id INT,
Date_Prinyatiya DATE
);
CREATE TRIGGER tr
BEFORE INSERT ON Sotrudnik
FOR EACH ROW
BEGIN
SET NEW.Date_Prinyatiya = NOW();
END
INSERT INTO Sotrudnik (id) VALUES (1);
SELECT * FROM Sotrudnik;
id | Date_Prinyatiya |
---|---|
1 | 2024-02-15 |
DROP TABLE Sotrudnik;
CREATE TABLE Sotrudnik (
id INT,
Date_Prinyatiya DATE DEFAULT (CURRENT_TIMESTAMP)
);
INSERT INTO Sotrudnik (id) VALUES (1);
SELECT * FROM Sotrudnik;
id | Date_Prinyatiya |
---|---|
1 | 2024-02-15 |