BossWangST
BossWangST

Reputation: 31

What is the difference between Retrieve and Query in DB?

I don't know the difference between Retrieve and Query in the field of Database. I learnt that query means that the user asks the DBMS for some info, but the retrieve operation seems to mean the same thing. I'm new to the DB. What are the differences?

Upvotes: 1

Views: 1835

Answers (3)

worbel
worbel

Reputation: 6585

From Difference between a statement and a query in SQL - Stack Overflow:

A query is a synonym for a SELECT statement.

From SQL example statements for retrieving data from a table:

An SQL SELECT statement retrieves records from a database table

From SQL - Wikipedia:

Queries, which retrieve the data based on specific criteria

Query typically means retrieve data so the terms are interchangeable. I have also seen query to also include data retrieval and manipulation. Interestingly, even in the same Wikipedia article as above, query includes UPDATE (modify records):

SQL query

Upvotes: 1

jordanvrtanoski
jordanvrtanoski

Reputation: 5557

From a perspective of user of the database, there is not difference at all. Retrieve is interchangeable with Query. When you want to retrieve data from database you will execute a query that will return the data. So as a developer, the difference is irrelevant.

Difference arrives from the perspective of the database. To query for the database means to parse the query statement, written in a query language, to compile the query in an executable code, to prepare the compiled code for execution and to schedule the execution. In this way, the database creates a cursor that will be used to fetch the data. Retrieve in this context means to travel trough the cursor, read the data and return it to the client.

Note that in this context, the query statement can also be used to store data in the database, and in this case, the cursor will return calculated fields or ids of the modified rows (depending from the database engine).

Read more from from wikipedia about Database and Data retrieval

Upvotes: 1

Nitish Prajapati
Nitish Prajapati

Reputation: 1

Retrieve means to get back things done earlier while query means to ask to do. Can like when using Pagination Data if we what you get data from 2nd Page you Retrieve from Same Database Table.

I think this might help you!!!

Upvotes: 0

Related Questions