Yes, it is possible with triggers. You can create trigger for automatic conversion on lower case. Let us first create a table −
mysql> create table DemoTable ( StudentSubject text ); Query OK, 0 rows affected (0.61 sec)
Let us create a trigger for automatic conversion on lower case −
mysql> CREATE TRIGGER lowerCaseOnInsertDemo BEFORE INSERT ON DemoTable FOR EACH ROW SET NEW.StudentSubject = LOWER(NEW.StudentSubject); Query OK, 0 rows affected (0.21 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('MOngoDb'); Query OK, 1 row affected (0.18 sec) mysql> insert into DemoTable values('JaVA'); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values('MySqL'); Query OK, 1 row affected (0.15 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output displaying the converted lowercase values −
+----------------+ | StudentSubject | +----------------+ | mongodb | | java | | mysql | +----------------+ 3 rows in set (0.00 sec)