Are you familiar with CRUD operations? If not, are you interested in what they are? Moreover, what they are used for? Confused? In this particular sense of the word, CRUD applies to a specific set of operations in data storage. This post is an introduction to a planned series of posts, in which I’ll focus on the SQL database aspect of its meaning. Actually, CRUD is an acronym that stands for: Create, Read, Update, Delete.
Why is CRUD important for those interested in learning SQL? Each individual letter part of the acronym stands for a word that is in fact, a basic – and important – SQL operation.
Before proceeding, let’s see how Wikipedia defines CRUD: Wikipedia defines CRUD as this:
“In computer programming, create, read, update, and delete[1] (CRUD) are the four basic functions of persistent storage”
So how do these 4 basic functions relate directly to SQL?
Create: Without rows of data, a database table doesn’t provide much value. The purpose of a table is to house data. But, how are new rows introduced into a table? With the
INSERT
statement. As we will see,INSERT
can create multiple rows of data at a time.Read: When a table has rows of data, generally that information is used as part of another process – or several – over its lifetime. How can you see the stored data? What values do the different table columns have? By using the
SELECT
statement.Update: Some data may never change. But, there is a chance that it could. Maybe you finally get to move to the country or city of your dreams. If your current residence (prior to your dream move) is stored in a database table somewhere, how does that information get changed? The
UPDATE
command. This particular element of the CRUD acronym so happens to share names with the actual SQL command of its action. I’ll go into more depth inUPDATE
‘s individual section, but I must mention that this command has the ability to affect (change) multiple rows of data, which in turn, should be used with caution.Delete: When rows of data are no longer wanted or needed, typically they are not kept. Perhaps some data is archived, even if never to be used again. But, if a row of data has to be removed from the table, the
DELETE
command will take care of it.DELETE
is a powerful command, capable of completely removing multiple rows of data. It is akin to theUPDATE
command in two ways: the word element of the acronym is the same as the SQL command and it too, should be used with caution.
Getting Started
If you want to follow along with the examples, you will need a SQL environment. Although I will use MySQL 8, the general principles themselves should carryover with minimal fuss to other SQL dialects. PostgreSQL is also a fantastic choice and can easily be used instead.
What can you expect to gain from these posts?
My goal is that after you have read the 4 posts that make up the series, you will have a solid understanding of:
- How to create new rows of data in a table.
- How to view the present data in a table.
- How to change (modify or alter) the present data in a table.
- How to remove present rows of data from a table.
Be sure and subscribe to the blog (via the button in the sidebar) to receive a notification when these posts (and others) are published.
Like what you have read? See anything incorrect? Please comment below and thanks for reading!!!
A Call To Action!
Thank you for taking the time to read this post. I truly hope you discovered something interesting and enlightening. Please share your findings here, with someone else you know who would get the same value out of it as well.
Visit the Portfolio-Projects page to see blog post/technical writing I have completed for clients.
Have I mentioned how much I love a cup of coffee?!?!
To receive email notifications (Never Spam) from this blog (“Digital Owl’s Prose”) for the latest blog posts as they are published, please subscribe (of your own volition) by clicking the โClick To Subscribe!โ button in the sidebar on the homepage! (Feel free at any time to review the Digital Owl’s Prose Privacy Policy Page for any questions you may have about: email updates, opt-in, opt-out, contact forms, etc…)
Be sure and visit the “Best Of” page for a collection of my best blog posts.
Josh Otwell has a passion to study and grow as a SQL Developer and blogger. Other favorite activities find him with his nose buried in a good book, article, or the Linux command line. Among those, he shares a love of tabletop RPG games, reading fantasy novels, and spending time with his wife and two daughters.
Disclaimer: The examples presented in this post are hypothetical ideas of how to achieve similar types of results. They are not the utmost best solution(s). The majority, if not all, of the examples provided, is performed on a personal development/learning workstation-environment and should not be considered production quality or ready. Your particular goals and needs may vary. Use those practices that best benefit your needs and goals. Opinions are my own.
One thought on “Introduction to SQL CRUD Basics.”