
- 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
How to set MySQL default value NONE?
To set the default value in MySQL, you need to use the DEFAULT keyword. Let us first create a table −
mysql> create table DemoTable ( ClientCountryName varchar(100) DEFAULT 'NONE' ); Query OK, 0 rows affected (0.65 sec)
We have set DEFAULT above for values not entered while insertion. Now, let us insert some records in the table using the insert command. We haven’t inserted values here for some of the rows. The DEFAULT gets set there −
mysql> insert into DemoTable values('US'); Query OK, 1 row affected (0.16 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.09 sec) mysql> insert into DemoTable values('UK'); Query OK, 1 row affected (0.20 sec) mysql> insert into DemoTable values(); Query OK, 1 row affected (0.15 sec) mysql> insert into DemoTable values('AUS'); Query OK, 1 row affected (0.16 sec)
Display all records from the table using select statement −
mysql> select *from DemoTable;
This will produce the following output −
+-------------------+ | ClientCountryName | +-------------------+ | US | | NONE | | UK | | NONE | | AUS | +-------------------+ 5 rows in set (0.00 sec)
- Related Questions & Answers
- How to set default Field Value in MySQL?
- How to set default value to NULL in MySQL?
- How to set default value for empty row in MySQL?
- Set default value to a JSON type column in MySQL?
- How to set NOW() as default value for datetime datatype in MySQL?
- How do I set the default value for a column in MySQL?
- Reset MySQL field to default value?
- How to modify column default value in MySQL?
- Set the default character set in MySQL
- How to revert rows to default column value in MySQL?
- How to set a default parameter value for a JavaScript function?
- How to set a default string value on a Tkinter Spinbox?
- How to use a function for default value in MySQL?
- MySQL UPDATE column names and set None values with N/A?
- Change tinyint default value to 1 in MySQL?
Advertisements