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
SQL
x
1
INSERT INTO table_name (column1, column2, ...)
2
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.
SQL
1
1
INSERT INTO Patients (first_name, last_name, dob, gender)
2
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.
SQL
1
1
INSERT INTO Patients (patient_id, first_name, last_name, dob, gender, contact_number)
2
VALUES (12, 'John', 'Doe', '1993-03-15', 'M', '555-1234');

SQL Insert Into Visual Diagram
