
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Can MySQL INT type be non-zero NULL?
You can set the INT column to value NULL.The column INT type a nullable column. The syntax is as follows:
INSERT INTO yourTableName(yourIntColumnName) values(NULL);
To understand the above syntax, let us create a table. The query to create a table is as follows:
mysql> create table nullableIntDemo -> ( -> Id int NOT NULL AUTO_INCREMENT, -> Price int, -> PRIMARY KEY(Id) -> ); Query OK, 0 rows affected (0.80 sec)
Insert the record as NULL for a int column ‘Price’. The query is as follows:
mysql> insert into nullableIntDemo(Price) values(NULL); Query OK, 1 row affected (0.11 sec) mysql> insert into nullableIntDemo(Price) values(100); Query OK, 1 row affected (0.15 sec) mysql> insert into nullableIntDemo(Price) values(200); Query OK, 1 row affected (0.12 sec) mysql> insert into nullableIntDemo(Price) values(NULL); Query OK, 1 row affected (0.13 sec) mysql> insert into nullableIntDemo(Price) values(NULL); Query OK, 1 row affected (0.10 sec)
Display all records from the table using select statement. The query is as follows:
mysql> select *from nullableIntDemo;
The following is the output:
+----+-------+ | Id | Price | +----+-------+ | 1 | NULL | | 2 | 100 | | 3 | 200 | | 4 | NULL | | 5 | NULL | +----+-------+ 5 rows in set (0.00 sec)
Look at the above sample output, in MySQL int column is a nullable.
- Related Questions & Answers
- Count zero, NULL and distinct values except zero and NULL with a single MySQL query
- MySQL index on column of int type?
- Insert NULL value into INT column in MySQL?
- Check if a number can be represented as sum of non zero powers of 2 in C++
- Which MySQL Data Type can be used to store Negative Number?
- Display first non-null values with coalesce() in MySQL?
- Perform mathematical calculations in a MySQL table with NULL and NON-NULL values
- Update all the fields in a table with null or non-null values with MySQL
- Add values of two columns considering NULL values as zero in MySQL
- Implicit return type int in C
- When can a double-type be preferred over float-type in Java?
- int(5) vs. int(10) in MySQL?
- Updating blank cells to NULL will cause all cells to be NULL in MySQL?
- Looping in JavaScript to count non-null and non-empty values
- HTML5 Input type=number removes leading zero
Advertisements