Insert NULL value into database field with char(2) as type in MySQL?

MySQLMySQLi Database

Let us first create a table −

mysql> create table DemoTable658(FirstName varchar(100),value char(2));
Query OK, 0 rows affected (0.95 sec)

Insert some records in the table using insert command −

mysql> insert into DemoTable658(FirstName) values('John') ;
Query OK, 1 row affected (0.19 sec)
mysql> insert into DemoTable658(value,FirstName) values(default(value),'Sam');
Query OK, 1 row affected (0.23 sec)

Display all records from the table using select statement −

mysql> select *from DemoTable658;

This will produce the following output −

+-----------+-------+
| FirstName | value |
+-----------+-------+
| John      | NULL  |
| Sam       | NULL  |
+-----------+-------+
2 rows in set (0.00 sec)
raja
Published on 21-Jan-2020 16:51:27
Advertisements