How is the insert statement used in SQL?
In SQL, the INSERT statement is used to add new rows (records) to a table. The basic syntax is as follows:
Add values into the table with specified columns in the following format: INSERT INTO table name (column1, column2, column3, …) VALUES (value1, value2, value3, …);
The table name denotes the name of the table where data is to be inserted, while column 1, column 2, column 3, etc. represent the names of the columns to insert data into, and value 1, value 2, value 3, etc. are the specific numerical values to be inserted.
For instance, to insert a new record into a table called “students” with columns id, name, and age, we can use the following INSERT statement:
Add a record for a student named John who is 20 years old into the students table with an ID of 1.
This will insert a new record into the students table with an id of 1, name ‘John’, and age 20.