In this Lesson, you will learn-
- 1.Different database queries.
- 2.Different database operators.
Query: A query is a request for data or information from a database table or combination of tables.
Types of query:
- 1.Select Query
- 2.Parameter Query
- 3.Crosstab Query
- 4.Action Query
Select Query: Select query is used to retrieve data from a table by selecting fields. It is the most used SQL query.
Parameter Query: A parameter query is one of the simplest and most useful queries that is done by taking input as a parameter from a dialog box, which is then used by the query in an expression or criteria. It is used when you want to create a query that you can use many times, but with a different value each time.
Crosstab Query: A crosstab query summarizes the data from one or more fields that are separated into groups based on one or more fields. Crosstab query is a type of select query. This query calculates a sum, average, or other aggregate function, and then groups the results.
Action Query: An action query is a query that makes changes to or moves many records in just one operation. There are four types of action queries: append, update, make-table, and delete.
- 1.Append Query– takes the set results of a query and “appends” (or adds) them to an existing table.
- 2.Delete Query– deletes all records in an underlying table from the set results of a query.
- 3.Make Table Query– as the name suggests, it creates a table based on the set results of a query.
- 4.Update Query– allows for one or more field in your table to be updated.
Query Language: Query languages are used to make queries in a database. These are some query languages-
- QUEL (Query Language)
- QBE (Query By Example)
- SQL (Structured Query Language)
SQL: SQL stands for Structured Query Language. SQL is a standard language for accessing and manipulating databases. SQL lets you access and manipulate databases. Although SQL is often described as, and to a great extent is, a declarative language (4GL). It also includes procedural elements. SQL consists of many types of statements, which may be informally classed as sublanguages, commonly:
- 1.Data query language (DQL)
- 2.Data definition language (DDL)
- 3.Data control language (DCL)
- 4.Data manipulation language (DML)
Database Operators: An operator is a reserved word or a character used primarily in an SQL statement’s WHERE clause to perform operation(s), such as comparisons and arithmetic operations. Different types of operators-
- Arithmetic Operators- You use the arithmetic operators to calculate a value from two or more numbers or to change the sign of a number from positive to negative or vice versa.
- Comparison Operators- You use the comparison operators to compare values and return a result that is True, False, or Null.
- Logical Operators- You use the logical operators to combine two Boolean values and return a true, false, or null result. Logical operators are also referred to as Boolean operators.
- Concatenation Operators- You use the concatenation operators to combine two text values into one.
- Special operators- You use the special operators to return a True or False result as described in the following table.
- a. What is Query?
- a. What is query language?
- a. What is SQL?
- a. What is DDL/DML?
- b. Explain the necessity of queries in database.
- b. Why SQL is called the soul of database?
- b. Why SQL is called very high level language?
- b. “SQL is a set of some statements” -Explain it.