CRUD Operations in Databases
CRUD Operations in Databases is a popular acronym for four basic operations when interacting with a database management system or working with APIs.
What is CRUD?
CRUD is an acronym for Create, Read, Update, and Delete, performing different operations regarding a database.
CRUD operations enable manipulation of any data available either by fetching these data, updating the data, deleting them, or adding more data.
Structured Query Language (SQL) for databases has functions mapped to CRUD operations:
Note: Enhance your data management skills with SQL training in Pune. Master the language of databases and unlock endless career opportunities
C for Create, how it works?
The Create operation is used to create a new record or entry to database table like user info, a new item, or a new row.
For example, for a database that contains user info like name, age, username, password, and unique ID, new user can be added with its info to database.
In SQL, create operation is mapped to the INSERT function, where the new values are inserted to their respective column as specified in the column list, as follows:
INSERT INTO users (name, age, email, password, id)
VALUES (value1, value2, value3, …);
R for Read, how it works?
The Read operation is used to read an entire database or search for one or more entries based on certain parameters.
For example, for database that contains user info, the entire list of users or a particular user info can be retrieved which can be referred to as READing.
In SQL, read operation is mapped to the SELECT function, as follows:
SELECT * FROM users;
Specific values from database tables can be read via column names, as follows:
SELECT name, age, email, password, id
Note: Enroll now in SevenMentor’s SQL Course in Pune to become a proficient SQL developer and gain a competitive edge in the IT industry.
U for Update, how it works?
The Update operation is used to modify existing data in database table.
In SQL, update operation is mapped to the UPDATE function, as follows:
SET name = ‘Mayuresh’
WHERE id = 123;
D for Delete, how it works?
The Delete operation is used to remove records from database table based on specified conditions. This is the direct opposite of the create operation.
In SQL, delete operation is mapped to the DELETE function, as follows:
DELETE FROM users
WHERE user_name = ‘Mayuresh’;
If all the records from the table can be deleted as follows:
DELETE FROM user;
In this tutorial, we discussed what each operation in the CRUD acronym means and works.
In summary, C represents Create and is used to create a new entry, R represents Read and is used to read an entry, U represents Update and modifies an entry, and D represents Delete and is used to delete an entry.
Do visit our channel to know more: Click Here
Call now!!! | SevenMentor Pvt Ltd.
© Copyright 2021 | SevenMentor Pvt Ltd.