SQL INSERT INTO Keyword
The INSERT INTO command is used to add new rows of data into a table. You can either insert values into all columns or only specific columns of a table.
SQL INSERT INTO Syntax
-- Insert into all columns INSERT INTO table_name VALUES (value1, value2, ...); -- Insert into specific columns INSERT INTO table_name (column1, column2, ...) VALUES (value1, value2, ...);
SQL INSERT INTO Students Table Example
This query adds a new student with a name only. The id will auto-increment.
INSERT INTO Students (name) VALUES ('Chloe');

SQL INSERT INTO Doctors Table Example
This query inserts a full record into the Doctors
table with a first name, last name, specialty, and contact number.
INSERT INTO Doctors (first_name, last_name, specialty, contact_number) VALUES ('Dr. Anna', 'Lee', 'Radiology', '555-1010');

SQL INSERT INTO Insert with Only Selected Columns Example
This query adds a new doctor, only filling the first and last name. Other columns will be NULL.
INSERT INTO Doctors (first_name, last_name) VALUES ('Dr. Kyle', 'Mendoza');
