- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Is it necessary to add DEFAULT NULL in MySQL?
No, it isn’t necessary because without adding DEFAULT NULL, it gives NULL value. For example, let’s say you haven’t added DEFAULT NULL and inserted a record with no value, then the result would display the NULL value as the inserted value.
Let us first create a table −
mysql> create table DemoTable ( FirstName varchar(100) ); Query OK, 0 rows affected (0.57 sec)
Insert some records in the table using insert command −
mysql> insert into DemoTable values('Chris'); Query OK, 1 row affected (0.13 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.12 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.21 sec) mysql> insert into DemoTable values('David'); Query OK, 1 row affected (0.12 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-----------+ | FirstName | +-----------+ | Chris | | NULL | | NULL | | David | +-----------+ 4 rows in set (0.00 sec)
- Related Articles
- Insert default into not null column if value is null in MySQL?
- How to set default value to NULL in MySQL?
- How to check whether column value is NULL or having DEFAULT value in MySQL?
- Adding a column whose value is not null by default in MySQL?
- How to add a NOT NULL column in MySQL?
- How to add not null constraint to existing column in MySQL?
- Why is it necessary to do sex?
- How to treat NULL as 0 and add columns in MySQL?
- How to add subtotal to a table column displaying NULL in MySQL?
- Why is it necessary to declare NOT FOUND handler while using MySQL cursor?\n
- Is it necessary to have a responsive website?
- Why is it necessary to conserve our environment?
- Why is it necessary to excrete waste products?
- How to add NOT NULL constraint to an already created MySQL column?
- Why it is necessary to balance the chemical equation?

Advertisements