INSERT INTO — Add New Data

The INSERT INTO statement allows you to add new rows to a table.
You can insert values for all columns or for specific columns.


Syntax (Insert All Columns)

INSERT INTO table_name VALUES (value1, value2, ...);

Syntax (Insert Specific Columns)

INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);

Example 1: Insert a New Employee (All Columns)

INSERT INTO employees VALUES (21, 'Emily', 29, 'IT', 'female');

This adds a new row to the employees table.

Example 2: Insert a New Employee (Specific Columns)

INSERT INTO employees (id, name, age) VALUES (22, 'Alex', 27);

This adds a new employee and leaves other columns as NULL or default.


Tip

  • You must match the order of columns with the order of values.
  • If you don’t specify columns, you must provide values for all columns.