Description

The SQL keyword INSERT INTO is used to insert one or more records into a database table.

  • Numeric values must not be enclosed within quotes.
  • Non-numeric values like strings, dates, etc., must always be enclosed within quotes.
  • Use the backslash to escape quotes within a non-numeric value.
    • Example: 'The user\'s profile'
  • No need to specify auto-increment or auto-generate columns in the INSERT query, as the database system automatically generates and assigns a value to such fields.

INSERT INTO Single Record

The below SQL inserts a single record into a table.

Run this on IDE

INSERT INTO employees (employee_name, gender, birth_date, hire_date, salary)
VALUES ('John Jacobs', 'M', '1996-10-21', '2015-11-10', 63000);

INSERT INTO Multiple Records

The below SQL inserts multiple records into a table, where the records are separated by a comma.

Run this on IDE

INSERT INTO employees (employee_name, gender, birth_date, hire_date, salary)
VALUES 
('Harry Potter', 'M', '1998-05-21', '2017-18-08', 52000),
('Jerry Thomas', 'F', '2001-08-25', '2019-07-07', 49000),
('Alice Conner', 'F', '1999-12-10', '2015-04-04', 55000);

Related Links