2. Concept of DDL, DML, DCL
Structured Query Language(SQL) as we all know is the
database language by the use of which we can perform
certain operations on the existing database and also we
can use this language to create a database. Sql uses
certain commands like Create, Drop, Insert, etc.
3.
4. DDL – Data Definition Language
Data Definition Language actually consists of the SQL commands that
can be used to define the database schema. It simply deals with
descriptions of the database schema and is used to create and modify
the structure of database objects in the database.DDL is a set of SQL
commands used to create, modify, and delete database structures but
not data. These commands are normally not used by a general user,
who should be accessing the database via an application.
5. ● CREATE: This command is used to create the database or its objects
(like table, index, function, views, store procedure, and triggers).
● DROP: This command is used to delete objects from the database.
● ALTER: This is used to alter the structure of the database.
● TRUNCATE: This is used to remove all records from a table,
including all spaces allocated for the records are removed.
● COMMENT: This is used to add comments to the data dictionary.
● RENAME: This is used to rename an object existing in the database.
6. DQL (Data Query Language)
DQL statements are used for performing queries on the data within
schema objects. The purpose of the DQL Command is to get some
schema relation based on the query passed to it. We can define
DQL as follows it is a component of SQL statement that allows
getting data from the database and imposing order upon it. It
includes the SELECT statement. This command allows getting the
data out of the database to perform operations with it. When a
SELECT is fired against a table or tables the result is compiled into
a further temporary table, which is displayed or perhaps received
by the program i.e. a front-end.
7. ● SELECT: It is used to retrieve data from the database.
8. DML(Data Manipulation Language)
DML or Data Manipulation Language and this includes most of
the SQL statements. It is the component of the SQL statement
that controls access to data and to the database. Basically, DCL
statements are grouped with DML statements
9. ● INSERT: It is used to insert data into a table.
● UPDATE: It is used to update existing data within a
table.
● DELETE : It is used to delete records from a database
table.
● LOCK: Table control concurrency.
● CALL: Call a PL/SQL or JAVA subprogram.
● EXPLAIN PLAN: It describes the access path to data.
10. DCL (Data Control Language)
DCL includes commands such as GRANT and REVOKE which mainly
deal with the rights, permissions, and other controls of the database
system.
● GRANT:This command gives users access privileges to the database.
● REVOKE: This command withdraws the user’s access privileges given by using the GRANT command.
12. ● Applications: – It can be considered as a user-friendly web
page where the user enters the requests. Here he simply...
● End User: – They are the real users of the database. They
can be developers, designers, administrators, or the
actual...
● DDL: – Data Definition Language (DDL) is a query fired to
create database, schema, tables, mappings, etc in the
database.
● DDL Compiler: – This part of the database is responsible
for processing the DDL commands. That means this
compiler...
13. Set operations
Union
Union combines two different results obtained by a query into a single result in the form of
a table. However, the results should be similar if union is to be applied on them.
Syntex:
Select Student_Name from Art_Students
UNION
Select Student_Name from Dance_Students
14. Intersection
The intersection operator gives the common data values between the two data
sets that are intersected. The two data sets that are intersected should be similar
for the intersection operator to work. Intersection also removes all duplicates
before displaying the result.
Syntex:
Select Student_Name from Art_Students
INTERSECT
Select Student_Name from Dance_Students
16. COUNT FUNCTION
● COUNT function is used to Count the number of rows in a database table. It can work on both numeric and non-
numeric data types.
● COUNT function uses the COUNT(*) that returns the count of all the rows in a specified table. COUNT(*)
considers duplicate and Null.
Syntax
1. COUNT(*)
2. or
3. COUNT( [ALL|DISTINCT] expression )
17. SUM Function
Sum function is used to calculate the sum of all selected columns. It works on numeric fields only.
Syntax
1. SUM()
2. or
3. SUM( [ALL|DISTINCT] expression )
18. AVG function
The AVG function is used to calculate the average value of the numeric type. AVG function returns the average of all
non-Null values.
Syntax
1. AVG()
2. or
3. AVG( [ALL|DISTINCT] expression )
19. MAX Function
MAX function is used to find the maximum value of a certain column. This function determines the largest value of all
selected values of a column.
Syntax
MAX()
1. or
2. MAX( [ALL|DISTINCT] expression )
20. MIN Function
MIN function is used to find the minimum value of a certain column. This function determines the smallest value of all selected
values of a column.
Syntax
1. MIN()
2. or
3. MIN( [ALL|DISTINCT] expression )
22. Domain Constraints
Domain Constraints are user-defined columns that help the user
to enter the value according to the data type. And if it encounters
a wrong input it gives the message to the user that the column is
not fulfilled properly. Or in other words, it is an attribute that
specifies all the possible values that the attribute can hold like
integer, character, date, time, string, etc.
23. Domain Constraints – Not Null: Null values are the values that are unassigned or we can also say that which are
unknown or the missing attribute values and by default, a column can hold the null values.
Create table employee
(employee_id varchar(30),
employee_name varchar(30) not null,
salary NUMBER);
24. Domain Constraints – Check: It defines a condition that each row must satisfy which means it restricts the
value of a column between ranges or we can say that it is just like a condition or filter checking before saving
data into a column. It ensures that when a tuple is inserted inside the relation must satisfy the predicate
given in the check clause.
Create table employee
(employee_id varchar(30) not
null check(employee_id > 0),
employee_name varchar(30),
salary NUMBER);
26. Domain constraints
● Domain constraints can be defined as the definition of a valid set of
values for an attribute.
● The data type of domain includes string, character, integer, time, date,
currency, etc. The value of the attribute must be available in the
corresponding domain.
27. Entity integrity constraints
● The entity integrity constraint states that primary key value can't be null.
● This is because the primary key value is used to identify individual rows in
relation and if the primary key has a null value, then we can't identify those
rows.
● A table can contain a null value other than the primary key field.
28. Referential Integrity Constraints
● A referential integrity constraint is specified between two tables.
● In the Referential integrity constraints, if a foreign key in Table 1
refers to the Primary Key of Table 2, then every value of the Foreign
Key in Table 1 must be null or be available in Table 2.
29. Key constraints
● Keys are the entity set that is used to identify an entity within its entity
set uniquely.
● An entity set can have multiple keys, but out of which one key will be
the primary key. A primary key can contain a unique and null value in
the relational table.