0% found this document useful (0 votes)
6 views2 pages

DBMS MICROOO FINAL

The document outlines SQL commands for creating and managing employee and customer tables, including inserting, updating, and selecting data. It also includes the creation of a CompDep table and a Student table, along with various operations on these tables. Additionally, it features cursor operations for processing records and outputting employee details based on salary criteria.

Uploaded by

jdfjds59
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)
6 views2 pages

DBMS MICROOO FINAL

The document outlines SQL commands for creating and managing employee and customer tables, including inserting, updating, and selecting data. It also includes the creation of a CompDep table and a Student table, along with various operations on these tables. Additionally, it features cursor operations for processing records and outputting employee details based on salary criteria.

Uploaded by

jdfjds59
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/ 2

1.create table employee ( 2. create table employee ( 3.

CREATE TABLE employee (


empno int primary key, empid int primary key, empid INT PRIMARY KEY,
ename VARCHAR(10) NOT NULL,
ename varchar(10) not null, ename varchar(10) not null,
manager INT,
job varchar(10), mgrid int, salary INT,
manager_no int, salary int, job VARCHAR(8),
sal int, job varchar(8) comm INT
comm int ); );
); alter table employee add comm int; ALTER TABLE employee ADD age INT;
DESC employee;
insert into employee values (1001, 'jay', 123, 1200, 'os', 3);
SELECT * FROM employee;
insert into employee values (1, 'abc', 'ss', 1, 25000, 3); insert into employee values (123, 'veer', 123, 30000, 'manager', 50); UPDATE employee SET age = 31 WHERE empid = 1001;
insert into employee values (2, 'xyz', 'os', 2, 23000, 2); insert into employee values (1002, 'raj', 123, 2000, 'turner', 3); UPDATE employee SET age = 28 WHERE empid = 1002;
insert into employee values (3, 'pqr', 'cs', 1, 18000, 2); insert into employee values (1003, 'vijay', 123, 3200, 'operator', 5); UPDATE employee SET age = 42 WHERE empid = 123;
insert into employee values (5, 'ee', 'op', 2, 12000, 1); insert into employee values (1004, 'seshu', 123, 2100, 'analyst', 4); UPDATE employee SET age = 31 WHERE empid = 1003;
insert into employee values (4, 'rr', 'yy', 3, 10000, null); insert into employee values (1005, 'john', 123, 2100, 'trainer', 2); UPDATE employee SET age = 28 WHERE empid = 1004;
UPDATE employee SET age = 22 WHERE empid = 1005;
select * from employee; commit;
SELECT * FROM employee;
commit; select * from employee; COMMIT;
update employee set job = 'trainer' where empid = 1005; SELECT empid, ename, age, salary FROM employee;
select * from employee; SELECT COUNT(empid) FROM employee;
desc employee; SELECT COUNT(ename) FROM employee;
alter table employee rename column mgrid to manager; SELECT MAX(age) FROM employee;
SELECT MIN(age) FROM employee;
desc employee;
SELECT empid, ename, age, salary FROM employee ORDER BY ename;
insert into employee values (105, 'sam', 123, 2100, 'run', 1); SELECT empid, ename, age, salary FROM employee ORDER BY salary;
select * from employee; SELECT empid, ename, salary FROM employee GROUP BY empid, ename,
delete from employee where empid = 105; salary ORDER BY empid;
select * from employee; SELECT salary, COUNT(*) FROM employee GROUP BY salary;

5. CREATE TABLE employee ( 6.CREATE TABLE CompDep (


empid INT PRIMARY KEY, Roll INT,
4. CREATE TABLE customer ( Name VARCHAR(20)
ename VARCHAR(10) NOT NULL,
id INT PRIMARY KEY, );
manager INT,
name VARCHAR(10) NOT NULL, CREATE TABLE Student (
salary INT,
age INT, Roll INT,
job VARCHAR(8),
address VARCHAR(10), Name VARCHAR(20)
comm INT, );
salary INT
age INT INSERT INTO Student VALUES (1, 'a');
);
); INSERT INTO Student VALUES (2, 'b');
INSERT INTO customer VALUES (1001, 'jay', 29, 'hubli', 21000);
INSERT INTO employee VALUES (1001, 'jay', 101, 21000, 'clerk', 0, 29); INSERT INTO Student VALUES (3, 'c');
INSERT INTO customer VALUES (1002, 'vijay', 32, 'gadag', 35000);
INSERT INTO employee VALUES (1002, 'vijay', 101, 35000, 'analyst', 0, 32); INSERT INTO Student VALUES (4, 'd');
INSERT INTO customer VALUES (1003, 'ram', 29, 'dharwad', 32000);
INSERT INTO employee VALUES (1003, 'ram', 101, 32000, 'engineer',0, 29); INSERT INTO CompDep VALUES (2, 'b');
INSERT INTO customer VALUES (1004, 'ajay', 28, 'delhi', 41000); INSERT INTO CompDep VALUES (5, 'e');
INSERT INTO employee VALUES (1004, 'ajay', 101, 41000, 'dev', 0, 28);
INSERT INTO customer VALUES (1005, 'delhi', 27, 'delhi', 27000); INSERT INTO CompDep VALUES (6, 'f');
INSERT INTO employee VALUES (1005, 'delhi', 101, 27000, 'admin', 0, 27);
UPDATE customer SET name = 'ram' WHERE id = 1005; COMMIT;
COMMIT;
UPDATE customer SET salary = salary + 1500 WHERE id = 1005; DECLARE
SET SERVEROUTPUT ON;
UPDATE customer SET salary = salary + 1500 WHERE id = 1003; CURSOR cu1 IS SELECT Roll, Name FROM Student;
DECLARE
UPDATE customer SET salary = salary + 1500 WHERE id = 1001; CURSOR cu2 IS SELECT Roll FROM CompDep;
var_record employee%ROWTYPE; rno INT;
SELECT * FROM customer;
CURSOR cur_test (max_sal NUMBER) IS nm VARCHAR(20);
SELECT * FROM employee WHERE salary < max_sal; rno2 INT;
BEGIN BEGIN
OPEN cur_test(58000); OPEN cu1;
LOOP OPEN cu2;
FETCH cur_test INTO var_record; LOOP
EXIT WHEN cur_test%NOTFOUND; FETCH cu1 INTO rno, nm;
DBMS_OUTPUT.PUT_LINE('EMP_ID: ' || var_record.empid || CHR(9) || FETCH cu2 INTO rno2;
EXIT WHEN cu1%NOTFOUND;
'Name: ' || var_record.ename || CHR(9) ||
IF rno2 <> rno THEN
'Salary: ' || var_record.salary || CHR(9) ||
INSERT INTO CompDep VALUES (rno, nm);
'Age: ' || var_record.age); END IF;
END LOOP; END LOOP;
CLOSE cur_test; CLOSE cu1;
END; CLOSE cu2;
/ END;
/
SELECT * FROM CompDep;
SELECT * FROM Student;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy