Lecture01 - DML DDL - Day - 1 - 2019 PDF
Lecture01 - DML DDL - Day - 1 - 2019 PDF
Email:[email protected]
WhatsApp: 0788465590
DML(Covered under DBMS)
The data type in DBMS(Oracle):
Data types already Char(size),varchar(size),varchar2(size), number(p,s), date, int,
covered: integer,float
Types for Large objects
BLOB Used to store large binary objects in the database. 8 to 128
terabytes (TB)
CLOB Used to store large blocks of character data in the database. 8 to
128 TB
Timestamp
TIMESTAMP TIMESTAMP data type to store valid date (year, month, day) with
time (hour, minute, second).
CREATE TABLE COMMAND
INSERTION OF DATA INTO TABLES
INSERTION OF DATA INTO TABLES
UPDATE STATEMENT
7
DELETE STATEMENT
8
SELECT STATEMENT
oSQL SELECT Statement is used to viewing data from the table. This
statement return list of table format table data.
oWe use asterisk (*) sign to fetch all table columns instead of write all
column name.
SQL SELECT Statement is used this four type:
SELECT All Rows and All Columns
SELECT All Rows and Selected Columns
Only Selected Rows and All Columns
Selected Rows and Selected Columns
38
SELECT Statement - Aggregates
39
SELECT Statement - Aggregates
40
SELECT Statement - Aggregates
41
Use of COUNT(*)
How many properties cost more than £350 per month to rent?
42
Use of COUNT(DISTINCT)
How many different properties viewed in May ‘04?
44
Use of MIN, MAX, AVG
45
SELECT Statement - Grouping
46
SELECT Statement - Grouping
All column names in SELECT list must appear in GROUP BY clause
unless name is used only in an aggregate function.
If WHERE is used with GROUP BY, WHERE is applied first, then
groups are formed from remaining rows satisfying predicate.
ISO considers two nulls to be equal for purposes of GROUP BY.
47
Use of GROUP BY
SELECT branchNo,
COUNT(staffNo) AS myCount,
SUM(salary) AS mySum
FROM Staff
GROUP BY branchNo
ORDER BY branchNo;
48
Restricted Groupings – HAVING clause
49
Use of HAVING
SELECT branchNo,
COUNT(staffNo) AS myCount,
SUM(salary) AS mySum
FROM Staff
GROUP BY branchNo
HAVING COUNT(staffNo) > 1
ORDER BY branchNo;
50