Practical 8to11 Output
Practical 8to11 Output
Practical: 08
SYNTAX:
GRANT PRIVILEGES (like create, select, insert, update, delete) ON TABLENAME TO
USERNAME
ADMIN SIDE
SYNTAX:
REVOKE PRIVILEGES (like create, select, insert, update, delete) ON TABLENAME
FROM USERNAME
ADMIN SIDE
1. REVOKE SELECT, INSERT, UPDATE ON STUDENT_INFO FROM ALPA;
2. revoke all on student_info from alpa
1
3130703 – DBMS Lab 3rd, CSE/IT
Practical: 09
SYNTAX:
COMMIT [ WORK ] [ COMMENT clause ] [ WRITE clause ] [ FORCE clause ];
WORK - Optional. It was added by Oracle to be SQL-compliant. Issuing the COMMIT with or
without the WORK parameter will result in the same outcome.
COMMENT clause - Optional. It is used to specify a comment to be associated with the current
transaction. The comment that can be up to 255 bytes of text enclosed in single quotes.
WRITE clause - Optional. It is used to specify the priority that the redo information for the
committed transaction is to be written to the redo log.
FORCE clause - Optional. It is used to force the commit of a transaction that may be corrupt or in
doubt.
INPUT:
SQL>commit;
RESULT:
Commit complete.
SYNTAX:
SAVEPOINT text_identifier
SYNTAX:
ROLLBACK [WORK] [TO [SAVEPOINT]' savepoint_text_identifier '];
ROLLBACK [WORK] [FORCE 'force_text'];
INPUT:
SQL>rollback;
RESULT:
Rollback complete.
Example:
2
3130703 – DBMS Lab 3rd, CSE/IT
BEGIN
UPDATE account set amount = 9000 WHERE acc_no = 101;
UPDATE account set city = ‘delhi’ WHERE acc_no = 101;
SAVEPOINT sp1;
3
3130703 – DBMS Lab 3rd, CSE/IT
Practical: 10
SYNTAX:
DECLARE
CURSOR <cursor_name> IS <SELECT statement^>
<cursor_variable declaration>
BEGIN
OPEN <cursor_name>;
FETCH <cursor_name> INTO <cursor_variable>;
.
.
CLOSE <cursor_name>;
END;
EXAMPLE:
DECLARE
acc_rcd account%ROWTYPE;
CURSOR acc_cur IS
SELECT * FROM ACCOUNT WHERE CITY = 'surat' and amount > 9000;
BEGIN
OPEN acc_cur;
FETCH acc_cur INTO acc_rcd;
DBMS_OUTPUT.PUT_LINE('Emp no: ' || acc_rcd.acc_no);
DBMS_OUTPUT.PUT_LINE('Emp Name: ' || acc_rcd.name);
CLOSE acc_cur;
END;
Output:
Emp no: 115
Emp Name: foram
Statement processed.
0.00 seconds
4
3130703 – DBMS Lab 3rd, CSE/IT
Practical: 11
SYNTAX:
EXAMPLE:
CREATE or REPLACE TRIGGER trg1
BEFORE
INSERT ON employee
FOR EACH ROW
BEGIN
:new.empname:= initcap(:new.empname);
END;
Output:
Trigger created.
0.02 seconds