You want to insert a new record in a Table. For example, here we have a employees table and you want to insert new records for all the employees who joined the company recently.
To add a new record in a table we use the INSERT statement with the VALUES clause.
INSERT INTO employees(id, name, gender, salary) VALUES (9, 'Jennifer', 'F', 8000)
And if you want to add multiple records at once, just add the values one by one after each other.
INSERT INTO employees(id, name, gender, salary) VALUES (10, 'George', 'M', NULL), (11, 'Matt', 'M', 10000)
And when you use the INSERT statement, if you want you can exclude the column name in the insert statement.
INSERT INTO employees VALUES (12, 'Bradley', 'M', 7000)
But keep in mind when you omit the column names from the INSERT statement, you have to pass all the values for each of the columns in the table and in the order in which each column resides in the table. You can check by running this query – SELECT * FROM table_name LIMIT 5.
If you like this post then please share it with others and subscribe to our blog below to learn more about data science.