
- Learn MySQL
- MySQL - Home
- MySQL - Introduction
- MySQL - Installation
- MySQL - Administration
- MySQL - PHP Syntax
- MySQL - Connection
- MySQL - Create Database
- MySQL - Drop Database
- MySQL - Select Database
- MySQL - Data Types
- MySQL - Create Tables
- MySQL - Drop Tables
- MySQL - Insert Query
- MySQL - Select Query
- MySQL - Where Clause
- MySQL - Update Query
- MySQL - Delete Query
- MySQL - Like Clause
- MySQL - Sorting Results
- MySQL - Using Join
- MySQL - NULL Values
- MySQL - Regexps
- MySQL - Transactions
- MySQL - Alter Command
- MySQL - Indexes
- MySQL - Temporary Tables
- MySQL - Clone Tables
- MySQL - Database Info
- MySQL - Using Sequences
- MySQL - Handling Duplicates
- MySQL - SQL Injection
- MySQL - Database Export
- MySQL - Database Import
Insert NULL value into database field with char(2) as type in MySQL?
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)
- Related Articles
- How to insert NULL into char(1) in MySQL?
- Java application to insert null value into a MySQL database?
- Insert NULL value into INT column in MySQL?
- Insert default into not null column if value is null in MySQL?
- How to insert NULL keyword as a value in a character type column of MySQL table having NOT NULL constraint?
- How to insert data into a MySQL database with Java?
- How to insert DECIMAL into MySQL database?
- MySQL database field type for search query?
- Insert datetime into another datetime field in MySQL?
- How do I insert a NULL value in MySQL?
- What role data type plays when I insert an empty string into a MySQL column which is declared as NOT NULL?
- How to Insert custom date into MySQL timestamp field?
- Select some data from a database table and insert into another table in the same database with MySQL
- Enum with NOT NULL in a MySQL field?
- Change value of decimal(19, 2) when inserting into the database in MySQL?

Advertisements