We will learn how to create, select, insert, update, and delete statements using stored procedures in SQL.
CREATE TABLE worker
(
id INTEGER NOT NULL PRIMARY KEY,
first_name VARCHAR(15),
last_name VARCHAR(15),
salary DECIMAL(10, 3),
)
Syntax for inserting data into a table is:
INSERT INTO table_name (column1, column2, column3, ...)
VALUES (value1, value2, value3, ...);
Example:
“INSERT INTO worker VALUES (2, 'Rajesh', 'Kumar', 6000,)”;
Syntax for selecting data into a table is:
SELECT * FROM table_name WHERE CONDITION;
Example:
“SELECT * FROM worker where `id` = 1”;
Syntax for updating data into a table.
UPDATE table SET `column1` = `Value1` = `column2` = `value2`, ... WHERE CONDITION;
Example:
UPDATE workers SET `first_name` = ”Rajesh”, `last_name` = “Kumar” WHERE `id` = 1;
Syntax for deleting data from a table.
DELETE FROM table_name WHERE condition;
Example:
DELETE FROM WORKERS WHERE `id` = 1;
Hence, it is possible to create a stored procedure in SQL that can handle select, add (insert), update, and delete operations on a database table.