Query Language
User can easily retrieve information or data from database with query language. Operations such as entering data, retrieving data, modifying or deleting data in the database are called queries. The language with which queries are made is called query language.
Most database management systems use query languages to access the database. It is a high-level language. Using this language, it is possible to easily search and collect data from the database and perform various calculations according to the user's wishes. This language is higher level than any standard programming language. SQL and QUEL query languages are currently used in microcomputers.
Name some query languages
(i) QUEL (Query Language)
(ii) QBE [Query by Example]
(iii) SQL (Structured Query Language)
(iv) Server SQL
Among these four query languages, SQL has gained the most popularity worldwide. According to ANSI standards, SQL has become the standard query language for relational databases.
SQL and its parts (Select From, Where)
What is SQL ?
SQL was developed in 1974 at IBM's San Jose Research Center. SQL is used as a data definition and data manipulation language in various relational database management systems.
SQL is built on Tuple Calculus. Currently, SQL is very popular as a query language.
The data manipulation statements of SQL are:
(i) SELECT statement
(ii) UPDATE statement and
(iii) INSERT statement.
Different parts of SQL.Two parts of SQL, viz--
(i) SQL and in data definition
(ii) Data Manipulation SQL.
They are described about--
1. SQL in Data Definition: Data definition language used to store data in database management systems. Database management systems store information in file structures.
The data definition statement is-
(i) CREATE statement
(ii) ALTER statement
(iii) CREATE INDEX statement.
2. Data Manipulation SQL: Data Manipulation Language is a language that allows the user to read data, add new data, delete data etc.
• There are two types of data manipulation languages--
(i) Procedural and
(ii) Non-Procedural.
Statement of data manipulation is-
(i) SELECT statement
(ii) UPDATE statement
(iii) DELETE statement
(iv) INSERT statement.
Basic Structure of SQL
SQL consists of three expressions, namely---
(i) Select
(ii) Form
(iii) Where.
Below is a sample SQL query structure
Select A1 A2........ An
Form r1. R2.......... Rn
Where P
Here A1 A2...An these are attributed.
R1. R2 An These are relations.
To see all the field records in the file named Predicate in P, the database management system student file has to be opened and browsed. Its command in query language is--
Select *:
From Student
Here this symbol means all the fields in the query language. A line break is indicated by the ':' symbol.
SQL Select and From Where operations:
If it is asked to create files for only Courses whose Course fee (Co-Fee) is Rs.5000 or more or Rs.7000 or less, then the command is as follows--
Select s1.- no, Course co-fee
From student: Where co-fee > 5000, or=<7000;
Order by s1 -no desc;
into table student 1
Two statements are described below--
(i) SELECT statement
SELECT [distinct] <target-list> FROM<relation-list>
[where, predicate>]
Distinct : All attributes to be displayed by default are to be specified here. Distinct clause should be used to avoid displaying any duplicate records in the query.
Target-list : List all the attributes to be displayed from a table. Multiple attribute names are separated by commas each.
Relation list: All the tables that will be evaluated i.e. all the tables from which the data will be selected must be mentioned in the <Relation_list> part with the form clause.
Predicate : Predicate is to be specified with where clause. Here any relation attribute as Predicate
Data can be relative from multiple tables by determining.
The UPDATE statement is used to modify one or more rows from a specified relation or table.
UPDATE <relation> set <target_value-list>
Where <predicate>
Relation: The relation or table in which the data will be corrected or modernized is mentioned here, it is a non-current table. If the table database is not open, the database name must also be specified here.
Target value_list t Columns to be updated with the new value. target_ value-list to specify its name. Each row of the column will be updated with the new value unless the Where clause is used.
Predicate : Predicate is used with where clause. All records will be updated with the new value. It is mentioned here. Filter condition criteria can be defined here. All records that meet the criteria will be considered for modernization.
x
Comments
Post a Comment