Let us first create a table −
mysql> create table DemoTable1584 -> ( -> DueDate datetime -> ); Query OK, 0 rows affected (1.79 sec)
Here is the query to insert DATE in a MySQL −
mysql> create trigger insertDate before insert on DemoTable1584 -> for each row set new.DueDate=curdate(); Query OK, 0 rows affected (0.22 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable1584 values(); Query OK, 1 row affected (0.66 sec) mysql> insert into DemoTable1584 values(); Query OK, 1 row affected (0.10 sec) mysql> insert into DemoTable1584 values(); Query OK, 1 row affected (0.07 sec)
Display all records from the table using select statement −
mysql> select * from DemoTable1584;
This will produce the following output −
+---------------------+ | DueDate | +---------------------+ | 2019-10-18 00:00:00 | | 2019-10-18 00:00:00 | | 2019-10-18 00:00:00 | +---------------------+ 3 rows in set (0.00 sec)