DEV Community

Punitha
Punitha

Posted on

CRUD Operations in SQL

  • CRUD stands for Create, Read, Update, and Delete.

  • These are the four basic operations used to manage data in a database.

  • SQL provides different commands to perform each of these operations.

CRUD stands for:

  • C -> Create

  • R -> Read

  • U -> Update

  • D -> Delete

Definition:

  • Create(INSERT) - The INSERT statement is used to add new records into a table.
INSERT INTO table_name(col1,col2,.....)
VALUES (value1,value2,.....);

INSERT INTO Student (Student_ID, Name, Marks)
VALUES (101, 'John', 90);
Enter fullscreen mode Exit fullscreen mode
  • Read(SELECT) - The SELECT statement is used to retrieve data from a table.
SELECT column_name
FROM table_name;

SELECT * FROM Student;
Enter fullscreen mode Exit fullscreen mode
  • Update - The UPDATE statement is used to modify existing records in a table
UPDATE table_name
SET column_name = value
WHERE condition;

UPDATE Student
SET Marks = 95
WHERE Student_ID = 101;
Enter fullscreen mode Exit fullscreen mode
  • Delete - The DELETE statement is used to remove records from a table
DELETE FROM Student
WHERE Student_ID = 101;

DELETE FROM Student
WHERE Student_ID = 101;
Enter fullscreen mode Exit fullscreen mode

Top comments (0)