CRUD Operations in SQL: Meaning, Examples, 5 Strengths and Weaknesses (Banking Example)

Are you new to SQL and wondering what CRUD operations really mean? If you have ever used a banking app to check your balance, transfer money or open a new account, you have already triggered CRUD operations without knowing it. These four simple actions, Create, Read, Update and Delete, are the backbone of every database-driven system, from a to-do app to a bank that manages millions of accounts.

In this guide I will explain CRUD operations in SQL in plain language, show you the exact syntax with code I have tested, and connect every step to a real banking example. We will also look at 5 strengths, 5 weaknesses and the safety habits that stop beginners from deleting the wrong data.

Last reviewed: November 2026

What Are CRUD Operations in SQL?

CRUD is a short name for the four basic things you can do with data stored in a table:

CRUD operations in SQL: Create, Read, Update and Delete
LetterOperationSQL statementBanking example
CCreateINSERTOpen a new account
RReadSELECTCheck your balance
UUpdateUPDATEWithdraw money or change email
DDeleteDELETERemove a failed transaction

One small thing confuses many beginners: the “Create” in CRUD means creating rows with INSERT, not creating tables. CREATE TABLE is a different kind of command (DDL) that builds the table itself. CRUD operations work on the data inside that table (DML).

Think of CRUD operations as the toolkit you need to manage data. If you are still new to databases, first read what is data and what is a database, then come back here.

Why Do CRUD Operations Matter?

Every software system that stores anything depends on CRUD operations. Your WhatsApp messages, your Swiggy order history, your school marks and your bank balance are all rows in some database, and every change to them is one of these four actions.

  • They are universal: SQL Server, MySQL, Oracle, PostgreSQL and even NoSQL databases like Google Cloud Firestore all support the same four ideas.
  • They are the first interview topic: Almost every SQL interview starts with them. See our SQL interview questions for practice.
  • They map to apps: Every screen in an app, like “Add”, “View”, “Edit” and “Remove”, is usually one CRUD operation underneath.

Setup: The Banking Tables

To practise CRUD operations, we need two tables: one for customers and one for their transactions. The IsActive column will help us later with a safer way to “delete”.

CREATE TABLE Customers (
    CustomerID INT PRIMARY KEY,
    Name       VARCHAR(100) NOT NULL,
    Email      VARCHAR(100),
    Balance    DECIMAL(10,2) NOT NULL DEFAULT 0,
    IsActive   BIT NOT NULL DEFAULT 1
);

CREATE TABLE Transactions (
    TxnID      INT PRIMARY KEY,
    CustomerID INT NOT NULL REFERENCES Customers(CustomerID),
    Amount     DECIMAL(10,2) NOT NULL,
    TxnType    VARCHAR(10) NOT NULL,
    Status     VARCHAR(10) NOT NULL
);

The REFERENCES part is a foreign key. It means every transaction must belong to a real customer. Keep this in mind, because it will protect us in the DELETE section.

CREATE: Adding New Data

CRUD operations example: INSERT, SELECT, UPDATE and DELETE in a bank database

When a new customer opens an account, the bank adds a row to the Customers table with INSERT. You can add one row or several rows at once:

INSERT INTO Customers (CustomerID, Name, Email, Balance)
VALUES (101, 'Ravi Kumar', 'ravi@example.com', 10000.00),
       (102, 'Anjali Verma', 'anjali@example.com', 2000.00),
       (103, 'Imran Shaikh', 'imran@example.com', 25000.00);

INSERT INTO Transactions (TxnID, CustomerID, Amount, TxnType, Status)
VALUES (1, 101, 5000.00, 'DEBIT', 'Success'),
       (2, 103, 15000.00, 'CREDIT', 'Success'),
       (3, 102, 12000.00, 'DEBIT', 'Failed');

Always list the column names, as above. If someone adds a new column to the table later, an INSERT without column names will break, but this one will keep working. Our full guide to the INSERT command covers more patterns.

READ: Retrieving Data

Reading is the most common of all CRUD operations. Every time you open your banking app, it runs a SELECT query behind the scenes.

SELECT Name, Balance
FROM Customers
WHERE CustomerID = 101;
Name        | Balance
------------+---------
Ravi Kumar  | 10000.00

Want to find every transaction above ₹10,000, which banks often review for fraud?

SELECT TxnID, CustomerID, Amount
FROM Transactions
WHERE Amount > 10000;
TxnID | CustomerID | Amount
------+------------+---------
2     | 103        | 15000.00
3     | 102        | 12000.00

Reading data lets you build reports, show account status and monitor suspicious activity. To go further with filters, sorting and joins, read our guide to the SELECT statement.

UPDATE: Modifying Existing Records

When Ravi withdraws ₹5,000, his balance must change. That is an UPDATE:

UPDATE Customers
SET Balance = Balance - 5000
WHERE CustomerID = 101;

Run the earlier SELECT again and Ravi’s balance now shows 5000.00. If he changes his email, the pattern is the same:

UPDATE Customers
SET Email = 'ravi.new@example.com'
WHERE CustomerID = 101;

Warning: the WHERE clause is everything. Without it, this command would change the email of every customer in the bank. Our UPDATE command guide explains more safety checks.

DELETE: Removing Records

Failed transactions are noise in reports, so the bank may remove them:

DELETE FROM Transactions
WHERE Status = 'Failed';

After this, only 2 transactions remain. Now try to delete a customer who still has transactions:

DELETE FROM Customers
WHERE CustomerID = 101;

This fails. SQL Server reports that the DELETE statement conflicted with the REFERENCE constraint, because Ravi still has a transaction in the Transactions table. That is the foreign key doing its job. Real banks must keep transaction history, so they almost never hard-delete customers.

The Safer Option: Soft Delete

Instead of removing the row, mark the account as inactive:

UPDATE Customers
SET IsActive = 0
WHERE CustomerID = 102;

SELECT Name
FROM Customers
WHERE IsActive = 1
ORDER BY Name;
Name
------------
Imran Shaikh
Ravi Kumar

Anjali’s account is hidden from active lists, but her history is still there for audits and can be restored if she returns. This is how most real systems handle “delete”.

Real-World Banking CRUD Operations Scenario

Let us follow one customer through the full journey. Each step is one of the CRUD operations:

  1. Priya opens an account. CREATE
  2. She logs in and checks her balance. READ
  3. She deposits ₹1,000. UPDATE
  4. Years later she closes the account. UPDATE (soft delete), or DELETE if the bank’s rules allow.
-- CREATE
INSERT INTO Customers (CustomerID, Name, Email, Balance)
VALUES (104, 'Priya Nair', 'priya@example.com', 2000.00);

-- READ
SELECT Balance FROM Customers WHERE CustomerID = 104;

-- UPDATE (deposit ₹1,000)
UPDATE Customers SET Balance = Balance + 1000 WHERE CustomerID = 104;

-- CLOSE ACCOUNT (soft delete)
UPDATE Customers SET IsActive = 0 WHERE CustomerID = 104;

CRUD Operations and Transactions

Some actions need more than one CRUD operation, and they must succeed or fail together. A money transfer is the classic example: take ₹2,000 from Imran and give it to Ravi. If the first UPDATE works but the second fails, money disappears.

A transaction solves this. In SQL Server:

BEGIN TRY
    BEGIN TRANSACTION;

    UPDATE Customers SET Balance = Balance - 2000 WHERE CustomerID = 103;
    UPDATE Customers SET Balance = Balance + 2000 WHERE CustomerID = 101;

    INSERT INTO Transactions (TxnID, CustomerID, Amount, TxnType, Status)
    VALUES (4, 103, 2000.00, 'TRANSFER', 'Success');

    COMMIT TRANSACTION;
END TRY
BEGIN CATCH
    ROLLBACK TRANSACTION;
    THROW;
END CATCH;

If any line fails, ROLLBACK undoes everything, so the balances stay correct. This “all or nothing” rule is the A (Atomicity) in ACID, one of the big reasons banks trust an RDBMS.

5 Strengths of CRUD Operations

  1. Simple to learn: Four commands cover most day-to-day database work. A beginner can be productive in a day.
  2. Works everywhere: The same CRUD operations work in SQL Server, MySQL, PostgreSQL and Oracle with only small syntax differences.
  3. Easy to secure: You can give a user permission to read but not delete, so access matches each role.
  4. Maps directly to apps: Screens and APIs are built around the same four actions, so developers and database teams speak the same language.
  5. Reliable with transactions: Combined with transactions, CRUD operations keep important data such as money consistent even when something fails.

5 Weaknesses and Risks of CRUD Operations

  1. One missing WHERE can be a disaster: UPDATE or DELETE without a WHERE clause changes every row.
  2. UPDATE and DELETE lose history: Once a value is overwritten, the old value is gone unless you keep an audit table.
  3. SQL injection: Building queries by joining user text into SQL lets attackers run their own commands.
  4. Performance on big tables: A large UPDATE or DELETE can lock a busy table and slow the whole app.
  5. Too simple for complex rules: Real business logic, such as “only allow withdrawals if the balance stays above ₹1,000”, needs constraints, transactions or stored procedures on top of basic CRUD.

CRUD Operations in Apps and REST APIs

If you build Android apps or websites, you will see CRUD operations outside SQL too. A REST API usually maps them to HTTP methods:

CRUDHTTP methodExample API callSQL underneath
CreatePOSTPOST /customersINSERT
ReadGETGET /customers/101SELECT
UpdatePUT / PATCHPATCH /customers/101UPDATE
DeleteDELETEDELETE /customers/101DELETE or soft delete

So when your mobile app shows a list, opens a detail page, saves an edit or removes an item, it is calling these CRUD operations through an API, which then runs the SQL on the server. Services like Google Cloud Run are a common place to host such APIs.

Pro Tips for Safe CRUD Operations in SQL Server

  • Run a SELECT first: Before any UPDATE or DELETE, run a SELECT with the same WHERE clause and check which rows come back.
  • Use parameterized queries: Never build SQL by joining user input. This is the main defence against SQL injection (OWASP).
  • Wrap related changes in a transaction: Especially when money or stock is involved.
  • Prefer soft deletes: Use an IsActive or Status column for customers, orders and anything you may need to audit later.
  • Keep foreign keys: They stop you from creating orphan rows or deleting data that other tables still need.
  • Clean up duplicates carefully: If bad data does get in, follow a safe method like the ones in our guide to deleting duplicate records.
  • Design tables well from the start: Normalization keeps each fact in one place, so one UPDATE fixes it everywhere.

Conclusion

CRUD operations are the four building blocks of every database: INSERT to create, SELECT to read, UPDATE to change and DELETE to remove. They are easy to learn, but in real systems like banking you also need WHERE clauses you have checked, foreign keys, transactions and soft deletes to keep data safe.

My advice: copy the tables above into SQL Server or any free database, run each command yourself, and watch how the data changes. Ten minutes of practice will teach you more than an hour of reading. For the full reference, see Microsoft’s T-SQL INSERT documentation.

FAQs on CRUD Operations

Q1: What are CRUD operations in SQL?
They are the four basic actions on table data: Create (INSERT), Read (SELECT), Update (UPDATE) and Delete (DELETE).

Q2: Is CREATE TABLE a CRUD operation?
No. CREATE TABLE is a DDL command that builds the table structure. The “Create” in CRUD means inserting rows with INSERT.

Q3: Which CRUD operation is used the most?
Read (SELECT). Most apps read data far more often than they change it.

Q4: What is the difference between DELETE and soft delete?
DELETE removes the row permanently. A soft delete keeps the row and marks it inactive with a column like IsActive, so it can be audited or restored.

Q5: Are CRUD operations only for SQL databases?
No. NoSQL databases, REST APIs and mobile apps use the same four ideas, often with different names such as POST, GET, PATCH and DELETE.

Q6: How do I make CRUD operations safe in production?
Check WHERE clauses with a SELECT first, use parameterized queries, wrap related changes in transactions, keep foreign keys and prefer soft deletes for important data.

Leave a Comment