SQL Insert Into

The SQL Insert Into is used to add new records into a table. You can insert data into a table either by specifying values directly or by selecting data from another table.

SQL Insert Into Syntax

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



SQL Insert Into Example

SQL Insert Into Only in Specified Columns Example

This INSERT query adds a new record to the Patients table with the specified values for the columns first_name, last_name, dob, and gender.

INSERT INTO Patients (first_name, last_name, dob, gender)
VALUES ('Jane', 'Doe', '1995-07-25', 'F');




SQL Insert Into in All Columns Example

This query successfully adds a new patient record with the specified details, provided that 12 is a unique patient_id and does not conflict with existing entries in the table.

INSERT INTO Patients (patient_id, first_name, last_name, dob, gender, contact_number)
VALUES (12, 'John', 'Doe', '1993-03-15', 'M', '555-1234');




SQL Insert Into Visual Diagram




SQL Insert Into Labs

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top