Insert Rows Using DEFAULT Values in SQL
📖 Scenario: You are managing a simple employee database for a small company. The table employees has columns for id, name, department, and salary. Some columns have default values set by the database.
🎯 Goal: Learn how to insert new rows into the employees table using the DEFAULT keyword to use default values for some columns.
📋 What You'll Learn
Create the
employees table with columns id, name, department, and salary.Set default values for
department as 'General' and salary as 30000.Insert a new employee providing only
id and name, using DEFAULT for department and salary.Insert another employee providing
id, name, and department, but use DEFAULT for salary.💡 Why This Matters
🌍 Real World
Many databases use default values to simplify data entry and ensure consistent data when some information is not provided.
💼 Career
Knowing how to use DEFAULT values and insert data efficiently is important for database administrators and developers managing real-world data.
Progress0 / 4 steps