Dbms Internal
Dbms Internal
Dbms Internal
name VARCHAR(50),
age INT,
gender CHAR(1),
grade VARCHAR(10)
);
Create table employee and execute all DML Commands. Create user also grant and revoke
privileges from user
name VARCHAR(50),
position VARCHAR(50),
department VARCHAR(50)
);
VALUES
UPDATE employee
WHERE emp_id = 3;
-- Grant SELECT and INSERT privileges on the 'employee' table to the user
Create table student and add 5 records also create view on student and insert, modify
delete record through view.
name VARCHAR(50),
age INT,
department VARCHAR(50)
);
-- Insert 5 records
-- Create a view
UPDATE student_view
WHERE roll_no = 1;
WHERE roll_no = 2;
Create table Employee and Department. Also assign primary key in employee table and
foreign key in Department table add 5 records in Department table.
dept_name VARCHAR(50)
);
emp_name VARCHAR(50),
dept_id INT,
);
Create table employee, add 5 records also use like operator 5 different ways to display
name of employee.
SELECT * FROM employee WHERE emp_name LIKE '__v%'; -- Two underscores then 'v'
SELECT * FROM employee WHERE emp_name NOT LIKE '%e%'; -- Does not contain e
DECLARE
num INT := 5;
fact INT := 1;
BEGIN
FOR i IN 1..num LOOP
fact := fact * i;
END LOOP;
END;
i) Write a PL/SQL program to print numbers largest number from three numbers.
DECLARE
a INT := 10;
b INT := 20;
c INT := 15;
largest INT;
BEGIN
IF a > b AND a > c THEN
largest := a;
ELSIF b > c THEN
largest := b;
ELSE
largest := c;
END IF;
DBMS_OUTPUT.PUT_LINE('Largest number is: ' || largest);
END;
iii) Write a PL/SQL program to print numbers from 1 to 50 using while loop.
DECLARE
i INT := 1;
BEGIN
DBMS_OUTPUT.PUT_LINE(i);
i := i + 1;
END LOOP;
END;
-- Arithmetic functions
-- String functions
SELECT LENGTH('Hello'), UPPER('hello'), LOWER('WORLD'), SUBSTR('Oracle', 2, 3), INSTR('Hello
World', 'o');
-- Date-Time functions
Consider the table Employee( Eid, Ename, Ecity, Ejob, dept, salary) write SQL query for
following:
i) Insert a record of employee
UPDATE Employee
Consider the table Student (name, marks, dept, age, place, phone, birthdate) Write SQL
query for following :
UPDATE Student
SET marks = 96
FROM Student
(v) To list student name who have marks less than 40.
Consider the structure for book table as Book-Master (bookid, bookname, author, no_of
copies, price) Write down SQL queries for following:
FROM Book_Master
GROUP BY author;
(iii) Display all books whose price is between ` 500 & ` 800.
(iv) Display all books with details whose name start with ‘D’.
(vi) Display all books whose number of copies are less than 10.
SELECT * FROM Book_Master
WHERE no_of_copies < 10;
EMP (empno, deptno, ename, salary, designation, join_date, DOB, dept_location). Write
down SQL queries for following:
FROM EMP
FROM EMP
FROM EMP;
FROM EMP;
SELECT ename
FROM EMP
Write a command to create table student (rollno, Stud_name, branch, class, DOB, City,
Contact_no) and write down queries for following:
stud_name VARCHAR(50),
branch VARCHAR(50),
class VARCHAR(20),
DOB DATE,
city VARCHAR(50),
contact_no VARCHAR(15)
);
INSERT INTO Student (rollno, stud_name, branch, class, DOB, city, contact_no)
VALUES (3, 'Charlie', 'Electrical', 'Third Year', '2000-03-22', 'Nashik', '7654321098');