Skip to main content

How do you insert a record into a table?

Inserting a new record into a table is done with the INSERT INTO command.

Syntax:

sql
INSERT INTO Table_Name (Field1, Field2, ..., FieldN) VALUES (Value1, Value2, ..., ValueN);

Example:

sql
INSERT INTO Employees (ID, Name, Age, DepartmentID) VALUES (1, 'Ivan', 30, 101);

Explanation:

  • INSERT INTO Employees, picks the table we're adding a record to.
  • (ID, Name, Age, DepartmentID), specifies which fields we're filling in.
  • VALUES (1, 'Ivan', 30, 101), the values for those fields.

Notes

  • Fields marked NOT NULL must be filled in.
  • If a field is auto-incrementing (e.g. ID), it can be left out, the database assigns a unique value on its own.

Put simply, INSERT INTO is the SQL command for adding one or several records to a table.

Short Answer

Interview ready
Premium

A concise answer to help you respond confidently on this topic during an interview.