SQL inserting NULL values
Inserting NULL values
The SQL INSERT statement can also be used to insert NULL value for a column.
Example:
Sample table: agents
To add values'A001','Jodi','London','.12','NULL' for a single row into the table 'agents' then, the following SQL statement can be used:
SQL Code:
INSERT INTO agents
VALUES ("A001","Jodi","London",.12,NULL);
SQL insert values in specific columns
The SQL INSERT INTO statement can also be used to insert one or more specific columns for a row. It is required to mention the column(s) name in the SQL query.
Example:
Sample table: agents
To add values'A001','Jodi', and ', 12' against the columns 'agent_code', 'agent_name' and 'commission' into the table 'agents', the following SQL statement can be used:
SQL Code:
INSERT INTO agents
(agent_code,agent_name,commission)
VALUES ("A001","Jodi",.12)
Here is a new document which is a collection of questions with short and simple answers, useful for learning SQL as well as for interviews.
Check out our 1000+ SQL Exercises with solution and explanation to improve your skills.
Previous: Insert statement
Next: Inserting the result of a query in another table
SQL: Tips of the Day
What's the difference between VARCHAR and CHAR?
VARCHAR is variable-length.
CHAR is fixed length.
If your content is a fixed size, you'll get better performance with CHAR.
Ref: https://bit.ly/3wl3ram
- Weekly Trends
- Python Interview Questions and Answers: Comprehensive Guide
- Scala Exercises, Practice, Solution
- Kotlin Exercises practice with solution
- MongoDB Exercises, Practice, Solution
- SQL Exercises, Practice, Solution - JOINS
- Java Basic Programming Exercises
- SQL Subqueries
- Adventureworks Database Exercises
- C# Sharp Basic Exercises
- SQL COUNT() with distinct
- JavaScript String Exercises
- JavaScript HTML Form Validation
- Java Collection Exercises
- SQL COUNT() function
- SQL Inner Join
We are closing our Disqus commenting system for some maintenanace issues. You may write to us at reach[at]yahoo[dot]com or visit us at Facebook