Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- DROP TABLE employee;
- DROP TABLE student5;
- DROP TABLE AUDIT_TRAIL;
- CREATE TABLE employee(
- empid NUMBER(5),
- empname VARCHAR2(50),
- address VARCHAR2(100),
- contactno NUMBER(10)
- );
- CREATE TABLE audit_trail(
- empid_val NUMBER(5),
- empname_val VARCHAR2(50),
- op_date DATE,
- operation VARCHAR2(100));
- INSERT INTO employee VALUES(1, 'Rupesh Nepal','KTM','98404050');
- CREATE OR REPLACE TRIGGER trig_audittrail
- after INSERT ON employee
- FOR each ROW
- BEGIN
- INSERT INTO audit_trail(
- empid_val,
- empname_val,
- op_date,
- operation)
- VALUES
- (
- :NEW.empid,
- :NEW.empname,
- SYSDATE,
- 'Record Insertion'
- );
- END trig_audittrail;
- SELECT * FROM AUDIT_TRAIL ;
- INSERT INTO employee VALUES(2, 'RAMU KAKA ','LALT','978343434');
- COMMIT;
- SELECT * FROM employee;
- DELETE FROM employee;
- COMMIT;
- INSERT INTO employee VALUES(15,'Nepal','PKH','980000405');
- COMMIT;
- SELECT empname, versions_starttime "START_DATE", versions_endtime
- "END_DATE"
- FROM EMPLOYEE versions BETWEEN scn minvalue AND maxvalue WHERE empid=1;
- CREATE TABLE student5(
- rollno NUMBER(4),
- name VARCHAR2(50),
- address VARCHAR2(50),
- contactno NUMBER(10)
- );
- INSERT INTO student5 VALUES(1,'student','KTM',1234);
- COMMIT;
- SELECT * FROM student5;
- UPDATE student5 SET name='Rupesh' WHERE rollno=1;
- SELECT * FROM student5 ;
- SELECT * FROM student5;
- ROLLBACK;
- SELECT * FROM student5;
- COMMIT;
- SELECT name, versions_starttime "START_DATE", versions_endtime
- "END_DATE"
- FROM STUDENT5 versions BETWEEN scn minvalue AND maxvalue WHERE rollno=1
- -- Create the table
- CREATE TABLE Employee (
- EMPNAME VARCHAR2(100),
- START_DATE TIMESTAMP,
- END_DATE TIMESTAMP
- );
- -- Insert values into the table
- -- Insert values into the table
- INSERT INTO Employee (EMPNAME, START_DATE, END_DATE) VALUES
- ('Rupesh Nepal', TO_TIMESTAMP('2024-06-17 17:32:40.000', 'YYYY-MM-DD HH24:MI:SS.FF3'), NULL);
- INSERT INTO Employee (EMPNAME, START_DATE, END_DATE) VALUES
- ('Rupesh Nepal', TO_TIMESTAMP('2024-06-17 17:37:10.000', 'YYYY-MM-DD HH24:MI:SS.FF3'), TO_TIMESTAMP('2024-06-17 17:37:10.000', 'YYYY-MM-DD HH24:MI:SS.FF3'));
- -- Commit the transaction
- COMMIT;
- SELECT * FROM EMPLOYEE
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement