CRUD (Create, Read, Update & Delete) in Computer Programming

Instructor: Martin Gibbs

Martin has 16 years experience in Human Resources Information Systems and has a PhD in Information Technology Management. He is an adjunct professor of computer science and computer programming.

In the context of programming for databases, CRUD is not a derogatory term. Instead, it is a process where data is handled. This lesson will define CRUD and provide examples of its use.


Far from being a negative term, CRUD simply defines the programming process involved when working with data and databases.

CRUD stands for Create, Read (or retrieve), Update, Delete. Let's say we have a music database which stores information for artists, albums, reviews, and genres. When programmers provide interactions with this database (often through stored procedures which we'll touch on shortly), the steps of CRUD are carried out as follows:

  • Create: A new artist is entered into the database.
  • Read: The new artist's information is displayed to the user or programmer.
  • Update: Artist information, such as notes and country of origin are added to the artist record.
  • Delete: If you aren't going to add any albums or songs for this artist, the artist can be deleted. Or, the artist record is removed for other reasons (duplicate entry, lack of information, or the artist is just really bad).

Deleting: A Word of Caution

When we are talking about delete, it is only removing that record from the database. Even though this can be done without consequence, what if you had already entered a record for an album tied to that artist record? Most relational databases will warn you if you try to do this, but don't depend on it. Make sure that related entries are also checked and updated. If you had an album tied to an artist that no longer existed and a new artist record re-used that ID, then you will have bad data in the database. In related databases, deleting a record can be a bit more complicated than just zapping a row of data. Be very careful in how you remove data!

Mapping CRUD to Actual Statements

Now we know what CRUD stands for and what these operations do. But how do they map to actual statements we can use in real code?

The table below explains each step of CRUD and explains its corresponding SQL statement.

Step SQL Statement Example
C(reate) INSERT INSERT Into tblArtist (artistName, notes)
R(ead) SELECT SELECT * FROM tblArtist
U(pdate) UPDATE UPDATE tblArtist SET notes = Perfect!
D(elete) DELETE DELETE * FROM tblArtist WHERE artistID = 10

The SQL statements listed are usually built into stored procedures, which are executable blocks of SQL. It gives the end user power to interact with the data, but in a controlled setting. You define the access they get. It isn't wide-open.

For example, a programmer or database administrator develops a routine called enterArtist, which the end user runs. The end user only has to enter a few of the data elements and the stored procedure takes care of the rest. One step in the procedure would be to check for an entry for an artist of the same name.


Let's look at some real CRUD code. In the code below, we are letting the user enter values for the certain fields, thus the symbol (@). It indicates a variable or form field being entered.


CRUD - Create SQL Code

To unlock this lesson you must be a Member.
Create your account

Register to view this lesson

Are you a student or a teacher?

Unlock Your Education

See for yourself why 30 million people use

Become a member and start learning now.
Become a Member  Back
What teachers are saying about
Try it risk-free for 30 days

Earning College Credit

Did you know… We have over 200 college courses that prepare you to earn credit by exam that is accepted by over 1,500 colleges and universities. You can test out of the first two years of college and save thousands off your degree. Anyone can earn credit-by-exam regardless of age or education level.

To learn more, visit our Earning Credit Page

Transferring credit to the school of your choice

Not sure what college you want to attend yet? has thousands of articles about every imaginable degree, area of study and career path that can help you find the school that's right for you.

Create an account to start this course today
Try it risk-free for 30 days!
Create an account