Assume that you have a database table called 'EMPLOYEE' with the following fields:
1. Id 2. Name 3. Address 4. Salary
The below examples demonstrate the sql statements to perform the CRUD operations.
INSERT INSERT INTO Employee (Id, Name, Address, Salary) VALUES (1, 'John', '8900 Research Park Dr', 1200)
The above statement will insert a new record into the employee table. The name of the employee used in the above example is 'John'.
UPDATE UPDATE Employee SET Name = 'Mr. John', Address = '', Salary = 1400 WHERE id = 1
DELETE DELETE FROM Employee WHERE id = 1
The above statement deletes the record of employee whoes Id is 1.
DELETE FROM Employee
There is no WHERE condition in the above statement and it will delete all records from employee table.
SELECT SELECT Id, Name, Address, Salary FROM Employee where ID = 1
The above sql statement finds the record of the employee with the ID = 1.
SELECT Id, Name, Address, Salary FROM Employee
In the above statement, there is no WHERE condition. So, it will return all records from the employee table.
|