SQLDAY 21
SQLDAY 21
CUSTOMER
CID CNAME CNO ADDDRESS
NUMBER(2) VARCHAR(10) NUMBER(10) VARCHAR(20)
PRODUCT
PID PNAME PRICE CID
NUMBER(2) VARCHAR(10) NUMBER(6,2) NUMBER(3)
UPDATE CUSTOMER
SET CNO =
7778889994
WHERE CNAME ='ABDUL' ;
UPDATE CUSTOMER
SET ADDRESS = 'MYSORE'
WHERE CID = 1 ;
5. WAQT hike the salary of the employee to 10% . If employees earn less than
2000 as a salesman .
TRUNCATE DELETE
Belongs to DDL Belongs to DML
We have 3 Statements :
1. COMMIT
2. ROLLBACK
3. SAVEPOINT
1. COMMIT : "This statement is used to SAVE the transactions into the DB ".
Syntax: COMMIT ;
Example :
Query WORKPLACE DATABASE
INSERT INTO T1
VALUES( 'A' , 100 ) ; NAMESAL NAMESAL
A100A100
COMMIT ;
NAME SAL
UPDATE T1 A 1000
SET SAL = 1000 B 200
WHERE NAME = 'A' ; C 300
2. ROLLBACK :
This statement is used to Obtain only the saved data from the DB .
It will bring you to the point where you have committed for the last time .
SYNTAX: ROLLBACK ;
3. SAVEPOINT :
Example :
"This statement is used to control the flow of data between the users ".
We have 2 statements :
1. GRANT
2. REVOKE
Example :
EMP SELECT *
ENAME SAL FROM SCOTT.EMP ;
A 100
B 200
EMP SELECT *
ENAME SAL FROM SCOTT.EMP ;
A 100
B 200
SELECT *
ENAME SAL FROM SCOTT.EMP ;
A 100
B 200
TRY !!!!
SQL> CONNECT
Enter user-name: SCOTT
Enter password: *****
Connected.
SQL> GRANT SELECT ON EMP TO HR;
Grant succeeded.
SQL> CONNECT
Enter user-name: HR
Enter password:
***** Connected.
SQL> SELECT *
2 FROM SCOTT.EMP;
What is Normalization ?
" It is the process of reducing a large table into smaller tables in order to remove
redundancies and anomalies by identifying their functional dependencies is
known as Normalization . "
Or
Or
T1 T2
T3
Note : If any Table / entity is reduced to 3NF , then the table is said to be normalized.
QSPIDERS
QID NAME COURSE
QID NAME C1 C2 C3
1 A JAVA
1 A JAVA MT
2 B JAVA , SQL
2 B JAVA SQL
3 C MT , SQL
3 C SQL MT
1 A MT
:- ( Eid , deptno ) -> ( Ename , Sal , Dname , Loc ) composite key attribute
results in PFD