0% found this document useful (0 votes)
14 views

Document

That's All

Uploaded by

msubhansaleem646
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Document

That's All

Uploaded by

msubhansaleem646
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Define database and it types?

A database is an organized collection of structured information, or data,


typically stored electronically in a computer system. A database is usually
controlled by a database management system (DBMS). Together, the data
and the DBMS, along with the applications that are associated with them,
are referred to as a database system, often shortened to just database.

Types Of Databases:
1. Relational database (RDBMS)
2. Non-Relational database (DBMS)

Define DDL Command’s

DDL (Data Definition Language) commands are used in databases to


define and manage the structure of database objects like tables,
indexes, and schemas. Key DDL commands include:

1. CREATE – Used to create new database objects.

2. ALTER – Used to modify an existing database object.

3. DROP – Used to delete database objects.

4. TRUNCATE – Used to remove all records from a table but keeps


its structure.

Define DML command’s


DML (Data Manipulation Language) commands are SQL commands used
to manipulate and interact with data in a database. These commands allow
users to insert, update, delete, and retrieve data. The main DML
commands are:

INSERT: Adds new rows of data to a table.


UPDATE: Modifies existing data within a table.
DELETE: Removes data from a table.
SELECT: Retrieves data from one or more tables.

Define Joins and its types

A JOIN in SQL is used to combine rows from two or more tables


based on a related column between them. Joins help retrieve data
from multiple tables efficiently by specifying how they should be
linked.

Types of Joins:

INNER JOIN:

Returns only the rows that have matching values in both tables.
If there's no match, the row is excluded.
LEFT (OUTER) JOIN:

Returns all rows from the left table and the matching rows from the
right table.
If there's no match, NULL values are returned for columns from the
right table.

RIGHT (OUTER) JOIN:

Returns all rows from the right table and the matching rows from the
left table.
If there's no match, NULL values are returned for columns from the
left table.

FULL (OUTER) JOIN:

Returns all rows when there is a match in either the left or the right
table.
If there's no match, NULL values are returned for non-matching rows.

CROSS JOIN:

Returns the Cartesian product of the two tables, i.e., all combinations
of rows from both tables.
Does not require any condition to match rows.

SELF JOIN:

A join where a table is joined by itself.


Typically used to compare rows within the same table.

Define Function’s and Stored Procedure

Function:
A function in SQL is a set of statements that perform a specific task and
return a value. It is used within queries to calculate or manipulate data.
Functions cannot modify data (like INSERT, UPDATE, or DELETE).
Stored Procedure:

A stored procedure is a set of SQL statements that can perform complex


tasks, including modifying data. It can accept parameters, execute
operations, and may or may not return a value. Unlike functions, it can
change the database (e.g., UPDATE, DELETE).

Define Clause’s

WHERE:

The WHERE clause is used to filter records at the row level, before any grouping
or aggregation takes place. It allows you to specify conditions that must be met
for a row to be included in the result set. It can operate on individual column
values and supports logical operators like AND, OR, and NOT.

GROUP BY:

The GROUP BY clause groups rows that have the same values in specified
columns into summary rows. It is typically used with aggregate functions like
COUNT, SUM, AVG, etc., to perform calculations on each group of rows. It must
follow the FROM and WHERE clauses in the SQL query.

HAVING:

The HAVING clause is used to filter results after they have been grouped by
GROUP BY. Unlike WHERE, which filters rows before grouping, HAVING filters
groups based on aggregate values. It is useful for applying conditions to the
results of aggregation, such as filtering out groups that don't meet certain criteria.
ORDER BY:

The ORDER BY clause is used to sort the result set in either ascending (ASC) or
descending (DESC) order, based on one or more columns. It can sort data in
multiple ways, either alphabetically or numerically, and it is always applied at the
end of the query execution process, after grouping, filtering, and aggregation.

Define Trigger’s & It Type’s

Triggers: A trigger is a set of SQL statements that automatically executes


or "fires" when certain events occur on a specified table or view in a
database. Triggers are used to enforce business rules, maintain data
integrity, or automate tasks like auditing or logging changes to data.

Types of Triggers:

1. BEFORE Trigger:

Executes before an insert, update, or delete operation is


performed on a table. It allows you to modify the data or
prevent the operation if certain conditions are met.

2. AFTER Trigger:

Executes after an insert, update, or delete operation has been


completed on a table. It's typically used for actions like logging
changes or updating related data in other tables.
3. INSTEAD OF Trigger:

Executes instead of the operation (insert, update, or delete) on


a view or table. It allows custom actions to be performed, such
as preventing or redirecting the operation.

You might also like