What is Database Query? Earlier we have talked about what is data and what is a database. Now is the time to discuss what is a database query. So let’s begin.
Before we start talking about database query, first we need to understand why we need to database query. Lets discuss a scenario here.
Remember the time when you wanted to register a complaint regarding your Internet speed. You called the internet service provider and told him about your complaint, he politely asked you for some information and then gave you a complaint reference number. He might have asked you your subscriber ID or your name with your home address or some other personal information that you provided to the service provider.
Have you ever thought about what he will do with that information that he asked? I will tell you, he will enter that information in his database management software and that software will run a query against the database. He will do to single out your Internet connection information such as Internet plan, service start date, how much Internet data you have remaining.
He asked that subscriber ID to make sure the complaint gets registered for the right user.
Normally when we work with SQL or Oracle or other database management software, we run the queries against the databases to perform CRUD operations. If you don’t know what CRUD means, it means Create, Read, Update, Delete.
A database query is a collection of words, that we execute against the database to find out some specific information from it or make some changes into the data or store some new data in the database.
There are several types of quries.
- Select Query
- Insert Query
- Delete Query
- Update Query
Select Query Example
SELECT * FROM TableName;
This query is used to pull out some specific information from the database.
Insert Query Example
INSERT INTO TableName VALUES (value1, value2, value3);
This query is used to create a new record in the database.
Delete Query Example
DELETE FROM TableName WHERE condition;
This is used to delete a specific record from the database. That specific record get identified by the condition after where keyword in the query.
Update Query Example
UPDATE TableName SET column1 = value1, column2 = value2, ... WHERE condition;
We use this query to update some specific records in the database.
The above-mentioned queries are just a few. The SQL has thousands of queries that we can run and manage the database. We will be talking about more queries in future articles so stay tuned.
Feel free to write feedback or suggestions. I would really appreciate it.
Take Care Guys!