Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
19 views

SQL (Structured Quary Language) : Nikhil Jha

The document discusses SQL and database concepts like data types, constraints, functions, joins, and subqueries. It provides details on SQL components like DDL, DML, DCL, and DQL statements. Table structures and SQL syntax for queries, aggregation, grouping and filtering are covered.

Uploaded by

mahasayrajesh
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)
19 views

SQL (Structured Quary Language) : Nikhil Jha

The document discusses SQL and database concepts like data types, constraints, functions, joins, and subqueries. It provides details on SQL components like DDL, DML, DCL, and DQL statements. Table structures and SQL syntax for queries, aggregation, grouping and filtering are covered.

Uploaded by

mahasayrajesh
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/ 9

SQL (Structured Quary Language)

Data: - data is a raw fact which describes the property of an object...


• PROPERTY - ATTRIBUTES
• OBJECT: - ENTITY

DATA BASE: - database is a place and medium where we are storing the data in
systematic and organised way....

in database we are performing one operation called CRUD.


• C- CREATE(INSERT)
• R-READ(RETRIEVE)
• U- UPDATE(MODIFY)
• D- DELETE (DROP)
DBMS (database management system)

• used to maintain and manage the database.


• security and Authorization
• the data will be in file format
• we use QUARY LANGUAGE
• BINARY VALUE (0,1)
RDBMS (relational database management system):
• maintain and manage the database.
• security and Authorization
• structured query language.
• store the data in the form of table.
RELATIONAL MODEL: -
• store the data in form of table
• DBMS follows relational model it will become RDBMS
• it is designed by the scientist called E F CODD.
TABLE: -
• combination of rows and columns.
• consist three types.
1. COLUMNS
2. ROWS
3. CELL.

NIKHIL JHA
SQL (Structured Quary Language)
1. COLUMNS: -
• vertical position of the table.
• known as attributes and field.
2. ROWS: -
• Horizontal position of the table.
• known as RECORD & TUPLES
3. CELL: -
• Smallest unit in the table called cell.
• intersection of rows and columns.

*********************************************************************
RULES OF E F CODD: four rules
• data inters to a cell must be a single value
• we can store the data in multiple table if needed we can establish the
connection between two tables with the help of key attributes.
• in RDBMS we store the data in the form of table .it includes meta data.
➢ META DATA: - details about the data which is given in table.
➢ it is auto generated
• data can be validated in two steps
1. By assigning data types
2. By assigning constraints.

DATA-TYPE: -
• what type of data to be store in a particular memory location
• five types.
1. CHAR
2. VARCHAR/ VARCHAR2
3. DATE
4. NUMBER
5. LARGE OBJECT.
#- CHARACTER LARGE OBJECT.
#- BINARY LARGE OBJECT.

NIKHIL JHA
SQL (Structured Quary Language)
1. CHAR: -
• it can accept 'A-Z', 'a-z’, '0-9', 'special character', alpha numeric.
• enclosed with single (' ').
• SYNTEX: - CHAR(SIZE).
• 2000 character.
• fixed length memory allocation.
2. VARCHAR: -

• it can accept 'A-Z', 'a-z’, '0-9', 'special character', alpha numeric.


• enclosed with single (' ').
• SYNTEX: - VARCHAR(SIZE).
• SIZE 2000.
• the data type follows variable length memory allocation.
• if unused block will be their memory will take it back.
2A. VARCHAR2:

• updating of varchar.
• size 4000
• using coz of storage
3.DATE :
• there are two format given by the Oracle which is 'DD/MM/YYYY' AND
'DD/MM/YY'.
• SYNTEX:- DATE
4.NUMBER:-
• SYNTEX:- NUMBER( PRECISION, [SCALE])
• scale is optional.
• default value for scale is 0.
5.LARGE OBJECT :-
• CHARACTER LARGE OBJECT:- USE TO STORE CHAR TILL 4GB.
SYNTEX: - CLOB
• BINARY LARGE OBJECT:-it is used to store binary value of image, mp3,mp4,
doc etc up to 4gb.
SYNTEX :- BLOB.

NIKHIL JHA
SQL (Structured Quary Language)
CONSTRAINT:
it is rule given to the column for validation.
TYPES OF CONSTRAINTS:
1. UNIQUE
2. NOT NULL
3. CHECK
4. PRIMARY KEY
5. Foreign KEY

1.UNIQUE:- it cannot accept duplicate or repeated value.


2. Not Null:- it cannot accept null value. Means empty
3.check:- it is extra validation assign to the column with some condition.
• if condition will satisfied it will become true.
4. PRIMARY KEY:: uniquely identifies the record.
• it is a combination of UNIQUE & NOT NULL constraints.
• in table it accepts only one primary key.
5.FORGEN KEY:- it can accept duplicate or null value.

• it can accept null value.


• it is not combination of unique or not null constraints
• the table can accept more then one foreign key.
• if column wants to become foreign key it is mandatory to be a primary key .
• it is presenting child table but it belongs to parant table.

NIKHIL JHA
SQL (Structured Quary Language)
OVERVIEW OF SQL STATEMENT :-
1. Data definition language (ddl)
2. Data manipulation language (DML)
3. Transection control language (TCL)
4. Data control language (DCL)
5. Data quary language (DQL)

1. DATA QUARY LANGUAGE:-


• it is used to fetch the data from the data base.
• four statement.
a. Select
b. Projection
c. Selection
d. Joins

a. SELECT:- it will fetch the data from the table and display.
b. PROJECTION:- it will fetch the data from the table by selecting only the
table.
c. Selection:- it will fetch the data from the table by selecting the both
rows and columns.
d. JOINS:- it will fetch the data from the multiple table simultaneously

*********************************************************************
FUNCTION :-
• block of code or list used to perform some specific task
• two types.

FUNCTION

USER DEFINED FUNCTION INBUILT FUNCTION

SINGLE ROW FN SINGLE ROW FN

1. MAX ()
2. MIN ()
3. SUM ()
4. AVG ()
5. COUNT ()
NIKHIL JHA
SQL (Structured Quary Language)
• multi row fn can't accept null value
• use more than 1 multi row inside select clause.
*********************************************************************
GROUP BY CLAUSE: -
• used to group the record
• executes after execution of from clause
• executes row by row.
• any clause executes after the group by clause will executes group by group.
Syntax:-
o select group fn / group by expression
o From table name
o Where<filter condition>
o Group by col name / exp.
HAVING CLAUSE: used to filter the groups.
Syntax:-
o select group fn / group by expression
o From table name
o Where<filter condition>
o Group by col name / exp.
o Having <group- filter - condition>.

*********************************************************************
SUB QUARY :-
• a query written inside another query.
• inner query executes first and produce the op
• the op of inner query will be given as ip to the outer query
• And the outer query will executes and produce the result
• there for outer query is completely dependent on inner query.
• two types of sub query:-
1. Mingle row
2. Multi row
• two types of sub query operator
1. All
2. Any

NIKHIL JHA
SQL (Structured Quary Language)
*********************************************************************
JOINS:-
• it is the process of RETRIEVE or fetch the data from multiple table
simultaneously.
• FIVE types
1. Cross join/ Cartesian join
2. Inner join / equi join
3. Outer join.
a. left outer join
b. Right outer join
c. Full outer join
4. Natural join.
5. Self join
1. Cross join: the record from table one will merge with all the record from table 2.
SYNTEX: Select col name
From tn 1, tn 2 ;
2. Inner join:- it is used to obtain only matching record.
SYNTEX- SELECT COL NAME
FROM TN 1, TN 2
WHERE<JOIN CONDITION>;
3. OUTER JOIN:- it is used to obtain unmatched records.
o Left outer join:- it is used to obtain matched record from both the table
as well as unmatched records from left table.
o Right outer join:- it is used to obtain matched record from both table
as well as unmatched records from right table.
o Full outer join:- it is used to obtain unmatched records from the both
table as well as matched record
4. Natural join:-

• whenever there is relation between two table it will act like inner join.
• whenever there is no relation between two table it will act like cross join .
___________________________________________

NIKHIL JHA
SQL (Structured Quary Language)
CORRELATED SUBQUARY: -
• A query written inside another query and inner and outer query are
dependent on each other it's known as co related sub query.
• Types:

1. LENGTH () 2. SUB-STR () 3. LASTDAY ()


4. CONCAT () 5. IN STR () 6. NVL ()
7. UPPER () 8. MOD () 9. TO-DATE ()
10. LOWER () 11. ROUND () 12. ADD-MONTHS ()
13. INIT CAP () 14. TRUNC () 15. RANK ()
16. REVERCE () 17. MONTHS-BETWEEMN () 18. DENCE_RANK ()
19. REPLACE () 20. TO-CHAR () 21. CASE ()
22. SYSDATE ()

SET OPERATOR:

• t is used to combine the result of two selected statements,


• Four type

1. UNION 2. UNION ALL 3. INTERSECTION 4. MINUS

1.UNION: IT IS USED to combine the result of two statements and it will remove duplicate value.

2. UNION ALL: it is used to combine the result of two statements or it will not remove the duplicate
value.

3. INTERSECTION: it is used to combine the result of two statements and ot will give the common
records between two statements

4. MINUS: it is used to display the records present in table 1 and the same records which are not
present in the result

PSEUDO CALUMN (FALSE COLUMN):

• Pseudo column or false column which are present in each and every table and must be
called explicitly.
• We have two types of pseudo column 1. ROW_ID 2.ROW_NUM

NIKHIL JHA
SQL (Structured Quary Language)
STATEMENTS:
1. DATA DEFNITION LANGUAGE (DDL)
2. DATA MANIPULATION LANGUAGE (DML)
3. DATA CONTROL LANGUAGE (DCL)
4. TRANSECTION CONTROL LANGUAGE (TCL)
5. DATA QUARY LANGUAGE (DQL)

1.DATA DEFNITION LANGUAGE:


• This language is used to construct, modify and remove an object from the
database.
• It has five statements.
1. CREATE: construct or build an object
2. REMOVE: change the name of an existing table
3. ALTER
4. TRUNCATE: delete permanently
5. DROP
2. DATA MANUPULATION LANGUAGE:

• It Is used to add, modify and remove object


• Three statements
1. INSERT: add the record in given table
2. UPDATE: update the existing table
3. DELETE: remove an particular record
3. TRANSECTION CONTROL LANGUAGE:
• Control the transection such as insert, update and delete
• Three statements
1. COMMIT: save the transaction between database
2. SAVE POINT: mark the position
3. ROLL BACK: get back to the latest commit point
4. DATA CONTROL LANGUAGE:
• It is used to control the flow of data between the user
• Two statements
1. GRANT: this is used to give permission
2. REVOKE: it is used to take back the given permission

NIKHIL JHA

You might also like