DBMS Printout 1 To 11 J 14 J15
DBMS Printout 1 To 11 J 14 J15
iii) UPDATE THE DAMAGE_AMOUNT FOR THE CAR WITH SPECIFIC REGNO IN THE
ACCIDENT WITH REPORT_NUMBER 12 TO 25000
UPDATE Participated SET damage_amount=25000 WHERE report_number=12;
1row updated.
SELECT *FROM Participated;
OUTPUT :
RESULT:
PROGRAM 02 :
i) Create the following tables by properly specfiying primay key and foreign key.
Employee_Details(Emp_no, Name, DOB, Address, DOJ, Mobile_Number, Department_no,
Salary)
Department_Details(Department_no,Department_name,Location)
CREATE TABLE department(
department_no int primary key,
department_name varchar(100),
location varchar(100));
Table DEPARTMENT created.
DESC department;
CREATE TABLE employee(
emp_no int primary key,
name varchar(100),
dob date,
address varchar(100),
doj date,
mobilenumber int,
department_no REFERENCES department(department_no) on DELETE CASCADE,
salary int
);
Table EMPLOYEE created.
DESC Employee;
iii) Select department_no from department_details and not in Employee_details using both
tables.
RESULT :
PROGRAM 03 :
OUTPUT :
RESULT :
PROGRAM 04 :
Create the following tables by specifying proper primary key and foreign key
Paintings(id,name,artist_id,listed_price)
Artists(id,first_name,last_name)
Collectors(id,first_name,last_name)
Sales(id,date,painting_id,artist_id,collector_id,sales_price)
CREATE TABLE Artists(
id INT PRIMARY KEY,
first_name VARCHAR(255),
last_name VARCHAR(255)
);
Table ARTISTS created.
DESC Artists;
CREATE TABLE Collectors(
id INT PRIMARY KEY,
first_name VARCHAR(255),
last_name VARCHAR(255) );
Table COLLECTORS created.
DESC Collectors;
CREATE TABLE Paintings(
id INT PRIMARY KEY,
name VARCHAR(255),
artist_id INT,
listed_price DECIMAL(10,2),
FOREIGN KEY (artist_id) REFERENCES Artists(id)
);
Table PAINTINGS created.
DESC Paintings;
CREATE TABLE Sales(
id INT PRIMARY KEY,
dates DATE,
painting_id INT,
artist_id INT,
collector_id INT,
sales_price DECIMAL(10,2),
FOREIGN KEY (painting_id) REFERENCES Paintings(id) on delete cascade,
FOREIGN KEY (artist_id) REFERENCES Artists(id)on delete cascade,
FOREIGN KEY (collector_id) REFERENCES Collectors(id) on delete cascade
);
Table SALES created.
DESC Sales;
insert into Artists values(1,'Sri','vidhya');
1 ROW INSERTED.
insert into Artists values(2,'Laura','madhavan');
1 ROW INSERTED.
insert into Artists values(3,'Nanthini','devi');
1 ROW INSERTED.
insert into Artists values(4,'Vasuki','elango');
1 ROW INSERTED.
insert into Artists values(5,'Mathesh','kumar');
1 ROW INSERTED.
select *from Artists;
insert into Paintings values(11,'nature',1,300.00);
1 ROW INSERTED.
insert into Paintings values(12,'dragons',1,700.00);
1 ROW INSERTED.
insert into Paintings values(13,'landscape',2,2800.00);
1 ROW INSERTED.
insert into Paintings values(14,'potrait',2,2300.00);
1 ROW INSERTED.
insert into paintings values(19,'cartoon',5,3000.00);
1 ROW INSERTED.
insert into Paintings values(15,'anime',3,250.0);
1 ROW INSERTED.
insert into Paintings values(16,'clouds',3,5000.00);
1 ROW INSERTED.
insert into Paintings values(17,'chess',3,50.00);
1 ROW INSERTED.
insert into Paintings values(18,'shakespeare',4,1300.00);
1 ROW INSERTED.
select *from Paintings;
insert into Collectors values(101,'Jay','witson');
1 ROW INSERTED.
insert into Collectors values(102,'Ferin','mark');
1 ROW INSERTED.
insert into Collectors values(103,'Senif','camone');
1 ROW INSERTED.
insert into Collectors values(104,'laura','fisher');
1 ROW INSERTED.
select *from collectors;
insert into Sales values(1001,'11-01-2021',13,2,104,12500.00);
1 ROW INSERTED.
insert into Sales values(1002,'12-02-2023',14,2,104,2300.00);
1 ROW INSERTED.
insert into Sales values(1003,'03-04-2021',11,1,102,300.00);
1 ROW INSERTED.
insert into Sales values(1004,'04-12-2020',16,3,103,14000.00);
1 ROW INSERTED.
insert into Sales values(1005,'12-02-2023',15,3,103,11200.00);
1 ROW INSERTED.
insert into Sales values(1006,'30-03-2022',17,3,103,50.00);
1 ROW INSERTED.
select *from Sales;
i. List paintings that are priced higher then the average.
SELECT name,listed_price FROM paintings WHERE listed_price > (select
avg(listed_price) from paintings);
ii. List all collectors who purchased paintings from our gallery.
SELECT first_name,last_name from collectors where id in (select collector_id from
sales);
iii. Total number of sales for each artists who has sold at least one painting in our gallery.
select a.first_name,sum(s.sales_price)
from artists a
join sales s
on a.id=s.artist_id
group by a.first_name
having count(s.sales_price)> 0;
iv. Calculate the number of paintings purchased enough our gallery for each
collector.
SELECT first_name,last_name,(SELECT count(*) AS paintings FROM sales
WHERE collectors.id = sales.collector_id) as count_painting FROM collectors;
v. Show the first name and the last name of the artists who had zero sales with our gallery.
SELECT first_name, last_name FROM artists WHERE NOT EXISTS (SELECT *
FROM sales WHERE sales.artist_id = artists.id);
vi. Find the total number of paintings which were and drawn the artists with the id=12.
SELECT COUNT(*) as Drawn_by_12 FROM paintings p JOIN artists a ON
p.artist_id = a.id WHERE a.id = 12;
vii. Display the first_name and last_name of collectors in both collectors and sales table.
SELECT Collectors.first_name, Collectors.last_name FROM Collectors JOIN Sales
ON Collectors.id = Sales.collector_id;
viii. Find the paintings which were drawn by “Laura” on the date “12.02.2023”.
SELECT * FROM sales s JOIN artists a ON s.artist_id = a.id WHERE a.first_name =
'Laura' AND s.dates = '12.02.2023';
ix. List the artists whose painting’s sales price is more then 10000.
SELECT artists.first_name,artists.last_name, sales.sales_price FROM artists INNER
JOIN sales ON artists.id = sales.artist_id WHERE sales.sales_price > 10000;
x. Find the Average sales price of artists where the average sales price is greater then 12000.
SELECT artists.id,AVG(sales.sales_price)
FROM sales
JOIN artists ON artists.id=sales.artist_id
GROUP BY artists.id
HAVING AVG(sales.sales_price)>1200;
xi. Display artists name,painting name and it’s sales price.
SELECT artists.first_name,artists.last_name, paintings.name, paintings.listed_price
FROM artists INNER JOIN paintings ON artists.id = paintings.artist_id;
xii. Display Paintings id,Sales id and Sales price.
SELECT painting_id, sales_price,sales.id as sales_id FROM sales INNER JOIN
paintings ON sales.painting_id = paintings.id;
xiii. Delete all the records of paintings whose sales price is less then 1000.
DELETE paintings,sales from paintings inner join sales on
paintings.id=sales.painting_id where sales.sales_price<1000;
4 rows deleted.
SELECT * FROM Paintings;
xiv. Create a duplicate copy of artists table with the name artist details.
CREATE table artist_details as select * from artists;
Table ARTIST_DETAILS created.
SELECT * from artist_details;
xv. Give a 2percent listed price raise to the paintings whose listed price is less than the average.
UPDATE Paintings SET listed_price = listed_price * 1.02 WHERE listed_price <
(SELECT AVG(listed_price) FROM Paintings);
3rows updated.
SELECT * from paintings;
OUTPUT :
RESULT :
PROGRAM 05 :
Create Table DEPARTMENT(DEPT_NAME Varchar(20),MANAGER_NAME Varchar(255));
Create Table EMPLOYEE(EMP_ID int,EMP_NAME Varchar(20),DEPT_NAME Varchar(255));
Create table student(reg_no int(3) primary key,sname varchar(20));
Create table course(cid int(3) primary key, cname varchar(20),s_id int(3), foreign key (s_id)
references student(reg_no));
INSERT INTO DEPARTMENT VALUES ( "IT", "ROHAN"),( "SALES", "RAHUL"),( "HR",
"TANMAY"),( "FINANCE", "ASHISH"),("MARKETING", "SAMAY");
INSERT INTO EMPLOYEE VALUES (1, "SUMIT", "HR"),(2, "JOEL", "IT"),(3, "BISWA",
"MARKETING"),(4, "VAIBHAV", "IT"),(5, "SAGAR", "SALES");
INSERT INTO STUDENT values(1,’AAA’),(2,’BBB’),(3,’CCC’),(4,’DDD’),(5,’EEE’);
INSERT INTO COURSE VALUES (101,’Intro to JAVA’,3),(102,’Data Science’,1),(103,’AI &
ML’,4), (104,’Python’,3);
1. Natural Join
SELECT * FROM EMPLOYEE NATURAL JOIN DEPARTMENT;
2. Equi join
select * from student s join course c where s.reg_no = c.s_id;
3. Outer join
i. Left outer join
SELECT * FROM DEPARTMENT d LEFT OUTER JOIN EMPLOYEE e ON d.DEPT_NAME =
e.DEPT_NAME;
ii. Right outer join
SELECT * FROM DEPARTMENT d RIGHT OUTER JOIN EMPLOYEE e ON d.DEPT_NAME =
e.DEPT_NAME;
iii. Full outer join
SELECT * FROM DEPARTMENT d LEFT OUTER JOIN EMPLOYEE e ON d.DEPT_NAME =
e.DEPT_NAME UNION SELECT * FROM DEPARTMENT d RIGHT OUTER JOIN EMPLOYEE e
ON d.DEPT_NAME
OUTPUT :
RESULT :
PROGRAM 06 :
Procedure Implementation
Creating the table ‘product_items’ and displaying the contents
SQL> create table product_items(itemid number(3), actualprice number(5), ordid number(4), prodid
number(4));
Table created.
SQL> insert into product_items values(101, 2000, 500, 201);
1 row created.
SQL> insert into product_items values(102, 3000, 1600, 202);
1 row created.
SQL> insert into product_items values(103, 4000, 600, 202); 1 row created.
SQL> select * from product_items;
Program for general procedure – selected record’s price is incremented by 500, executing the
procedure created and displaying the updated table
SQL> create procedure itsum(identity number, total number) is price number;
2 null_price exception;
3 begin
4 select actualprice into price from product_items where itemid=identity;
5 if price is null then
6 raise null_price;
7 else
8 update product_items set actualprice=actualprice+total where itemid=identity;
9 end if;
10 exception when null_price then
12 dbms_output.put_line('price is null');
13 end;
14 /
Procedure created.
RESULT :
PROGRAM 07 :
DCL COMMANDS
mysql> create database dcl;
Query OK, 1 row affected (0.03 sec)
mysql> use dcl;
Database changed
mysql> show databases;
mysql> create user tom;
Query OK, 0 rows affected (0.07 sec)
mysql> create user john;
Query OK, 0 rows affected (0.02 sec)
mysql> create user allison;
Query OK, 0 rows affected (0.03 sec)
mysql> create table student(roll_no int(255),name varchar(100),branch varchar(100),age int(255));
Query OK, 0 rows affected, 2 warnings (0.04 sec)
mysql> insert into student values(10,'anitha','CSE',14);
Query OK, 1 row affected (0.01 sec)
mysql> insert into student values(14,'bavani','ECE',15);
Query OK, 1 row affected (0.03 sec)
mysql> insert into student values(16,'vikranth','EEE',16);
Query OK, 1 row affected (0.01 sec)
mysql> insert into student values(17,'yamini','civil',18);
Query OK, 1 row affected (0.03 sec)
mysql> insert into student values(19,'krishna','mech',20);
Query OK, 1 row affected (0.03 sec)
mysql> select * from student;
mysql> GRANT all on student to allison;
Query OK, 0 rows affected (0.02 sec)
mysql> show grants for allison;
mysql> GRANT select,insert,update on student to john;
mysql> show grants for john;
mysql> GRANT select,insert,update,delete on student to tom;
Query OK, 0 rows affected (0.03 sec)
mysql> show grants for tom;
mysql> REVOKE select, update on student from john;
Query OK, 0 rows affected (0.03 sec)
mysql> show grants for john;
mysql> REVOKE delete on student from tom;
Query OK, 0 rows affected (0.02 sec)
mysql> show grants for tom;
mysql> REVOKE all on student from allison;
Query OK, 0 rows affected (0.03 sec)
mysql> show grants for allison;
TCL COMMANDS
mysql> drop database account_details;
Query OK, 1 row affected (0.02 sec)
mysql> create database account_details;
Query OK, 1 row affected (0.00 sec)
mysql> show databases;
mysql> use account_details;
Database changed
mysql> create table account_details(account_no int(50),customer_name varchar(100),address
varchar(100),phone_no int(50),amount decimal(50));
Query OK, 0 rows affected, 2 warnings (0.01 sec)
mysql> insert into account_details values(101,'raj','kk nagar',56789,20000);
Query OK, 1 row affected (0.01 sec)
mysql> insert into account_details values(102,'ravi','mgr nagar',59713,10000);
Query OK, 1 row affected (0.00 sec)
mysql> insert into account_details values(103,'selvam','royal nagar',89436,17500);
Query OK, 1 row affected (0.00 sec)
mysql> insert into account_details values(104,'ananthi','transport nagar',94682,35000);
Query OK, 1 row affected (0.00 sec)
mysql> insert into account_details values(105,'jansi','padma nagar',67823,10900);
Query OK, 1 row affected (0.00 sec)
mysql> select*from account_details;
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)
mysql> commit;
Query OK, 0 rows affected (0.00 sec)
mysql> insert into account_details values(106,'rajaboopathi','jk nagar',90807,28000);
Query OK, 1 row affected (0.00 sec)
mysql> savepoint stu1;
Query OK, 0 rows affected (0.00 sec)
mysql> select*from account_details;
mysql> update account_details set amount=19000 where account_no=104;
Query OK, 1 row affected (0.00 sec)
Rows matched: 1 Changed: 1 Warnings: 0
mysql> savepoint stu2;
Query OK, 0 rows affected (0.00 sec)
mysql> select*from account_details;
mysql> delete from account_details where account_no=105;
Query OK, 1 row affected (0.00 sec)
mysql> start transaction;
Query OK, 0 rows affected (0.00 sec)
mysql> delete from account_details where account_no=105;
Query OK, 0 rows affected (0.00 sec)
mysql> savepoint stu3;
Query OK, 0 rows affected (0.00 sec)
mysql> select*from account_details;
mysql> ROLLBACK TO SAVEPOINT stu3;
Query OK, 0 rows affected (0.00 sec)
mysql> select*from account_details;
OUTPUT :
+--------------------+
| Database |
+--------------------+
| dcl |
| user1 |
| user2 |
| user3 |
| world |
+--------------------+
mysql> select * from student;
+---------+----------+--------+------+
| roll_no | name | branch | age |
+---------+----------+--------+------+
| 10 | anitha | CSE | 14 |
| 14 | bavani | ECE | 15 |
| 16 | vikranth | EEE | 16 |
| 17 | yamini | civil | 18 |
| 19 | krishna | mech | 20 |
mysql> show grants for allison;
+------------------------------------------------------+
| Grants for allison@% |
+------------------------------------------------------+
| GRANT USAGE ON *.* TO `allison`@`%` |
| GRANT ALL PRIVILEGES ON `dcl`.`student` TO `allison`@`%` |
+------------------------------------------------------+
+---------------------------------------------------------------+
| Grants for john@% |
+---------------------------------------------------------------+
| GRANT USAGE ON *.* TO `john`@`%` |
| GRANT SELECT, INSERT, UPDATE ON `dcl`.`student` TO `john`@`%` |
+---------------------------------------------------------------+
2 rows in set (0.02 sec)
+-----------------------------------------------------------------------+
| Grants for tom@% |
+-----------------------------------------------------------------------+
| GRANT USAGE ON *.* TO `tom`@`%` |
| GRANT SELECT, INSERT, UPDATE, DELETE ON `dcl`.`student` TO ` tom `@`%` |
+-----------------------------------------------------------------------+
2 rows in set (0.00 sec)
+----------------------------------+
| Grants for john@% |
+----------------------------------+
| GRANT USAGE ON *.* TO `john`@`%` |
| GRANT INSERT ON `dcl`.`student` TO `john`@`%` |
+----------------------------------+
1 row in set (0.00 sec)
+----------------------------------+
| Grants for tom@% |
+----------------------------------+
| GRANT USAGE ON *.* TO ` tom`@`%` |
| GRANT SELECT, INSERT, UPDATE ON `dcl`.`student` TO ` tom `@`%` |
+----------------------------------+
1 row in set (0.00 sec)
+------------+---------------+-----------------+----------+--------+
| account_no | customer_name | address | phone_no | amount |
+------------+---------------+-----------------+----------+--------+
| 101 | raj | kk nagar | 56789 | 20000 |
| 102 | ravi | mgr nagar | 59713 | 10000 |
| 103 | selvam | royal nagar | 89436 | 17500 |
| 104 | ananthi | transport nagar | 94682 | 19000 |
| 106 | rajaboopathi | jk nagar | 90807 | 28000 |
+------------+---------------+-----------------+----------+--------+
5 rows in set (0.00 sec)
+------------+---------------+-----------------+----------+--------+
| account_no | customer_name | address | phone_no | amount |
+------------+---------------+-----------------+----------+--------+
| 101 | raj | kk nagar | 56789 | 20000 |
| 102 | ravi | mgr nagar | 59713 | 10000 |
| 103 | selvam | royal nagar | 89436 | 17500 |
| 104 | ananthi | transport nagar | 94682 | 19000 |
| 105 | jansi | padma nagar | 67823 | 10900 |
| 106 | rajaboopathi | jk nagar | 90807 | 28000 |
+------------+---------------+-----------------+----------+--------+
6 rows in set (0.00 sec)
+------------+---------------+-----------------+----------+--------+
| account_no | customer_name | address | phone_no | amount |
+------------+---------------+-----------------+----------+--------+
| 101 | raj | kk nagar | 56789 | 20000 |
| 102 | ravi | mgr nagar | 59713 | 10000 |
| 103 | selvam | royal nagar | 89436 | 17500 |
| 104 | ananthi | transport nagar | 94682 | 19000 |
| 106 | rajaboopathi | jk nagar | 90807 | 28000 |
+------------+---------------+-----------------+----------+--------+
5 rows in set (0.00 sec)
RESULT :
PROGRAM 08 :
To create a simple trigger that does not allow insert update and delete operations on the table
SQL> create trigger trigg1 before insert or update or delete on employee for each row
2 begin
3 raise_application_error(-20010,'You cannot do manipulation');
4 end;
5/
Trigger created.
SQL> insert into employee values('aaa',14,34000);
insert into employee values('aaa',14,34000)
To drop the created trigger
SQL> drop trigger trigg1;
Trigger dropped
To create a trigger that raises an user defined error message and does not allow updation and
insertion
SQL> create trigger trigg2 before insert or update of salary on employee for each row
2 declare
3 triggsal employee.salary%type;
4 begin
5 select salary into triggsal from employee where eid=12;
6 if(:new.salary>triggsal or :new.salary<triggsal) then
7 raise_application_error(-20100,'Salary has not been changed');
8 end if;
9 end;
10 /
Trigger created.
SQL> insert into employee values ('bbb',16,45000);
insert into employee values ('bbb',16,45000)
OUTPUT :
* ERROR at line 1:
ORA-20010: You cannot do manipulation
ORA-06512: at "STUDENT.TRIGG1", line 2
ORA-04088: error during execution of trigger 'STUDENT.TRIGG1'
SQL> delete from employee where ename='xxx';
delete from employee where ename='xxx'
*
ERROR at line 1:
ORA-20010: You cannot do manipulation
ORA-06512: at "STUDENT.TRIGG1", line 2
ORA-04088: error during execution of trigger 'STUDENT.TRIGG1'
SQL> update employee set eid=15 where ename='yyy';
update employee set eid=15 where ename='yyy'
*
ERROR at line 1:
ORA-20010: You cannot do manipulation
ORA-06512: at "STUDENT.TRIGG1", line 2
ORA-04088: error during execution of trigger 'STUDENT.TRIGG1'
*
ERROR at line 1:
ORA-04098: trigger 'STUDENT.TRIGG2' is invalid and failed re-validation
SQL> update employee set eid=18 where ename='zzz';
update employee set eid=18 where ename='zzz'
*
ERROR at line 1:
ORA-04298: trigger 'STUDENT.ITTRIGGS' is invalid and failed re-validation
RESULT :
PROGRAM 09 :
VIEW:
create table Instructor(
id number Primary Key,
name varchar(90),
dept_name varchar(80),
salary number);
Table INSTRUCTOR created.
DESC Instructor;
create table Department(
department_name varchar(80),
building varchar(70),
budget number);
Table DEPARTMENT created.
DESC Department;
SELECT * FROM Instructor;
SELECT * FROM Department;
CREATING A VIEW ‘sample_instructor’ FOR THE TABLE ‘Instructor’
CREATE VIEW sample_instructor as select id,name,dept_name from Instructor;
View SAMPLE_INSTRUCTOR created.
SELECT DISTINCT * FROM sample_instructor;
PERFORMING INSERT OPERATION
INSERT INTO sample_instructor VALUES(401,'Allison','mech');
1 row inserted.
SELECT * FROM sample_instructor;
PERFORMING UPDATE OPERATION
UPDATE sample_instructor SET name='scott' WHERE id=106;
1 row updated.
SELECT * FROM sample_instructor;
PERFORMING DELETE OPERATION
DELETE FROM sample_instructor WHERE ID=400;
1 row deleted.
SELECT * FROM sample_instructor;
CREATING A VIEW ‘instructor_department’ USING BOTH THE TABLES ‘Instructor’ AND
‘Department’
create view instructor_department as
select id,name,building from instructor,department
where department.deptment_name=instructor.dept_name;
View INSTRUCTOR_DEPARTMENT created.
SELECT DISTINCT * FROM instructor_department;
OUTPUT :
RESULT :
PROGRAM 10 :
Register an XML Schema
DECLARE
l_schema CLOB; BEGIN
l_schema := '<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema attributeFormDefault="unqualified" elementFormDefault="qualified"
xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="MAILS">
<xs:complexType>
<xs:sequence>
<xs:element name="MAIL" maxOccurs="unbounded" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element type="xs:string" name="TO_"/>
<xs:element type="xs:string" name="FROM_"/>
<xs:element type="xs:string" name="HEADING_"/>
<xs:element type="xs:string" name="BODY_"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
DBMS_XMLSCHEMA.registerSchema(schemaurl=>'student.xsd', schemadoc => l_schema,
local => TRUE,
gentypes =>FALSE,
gentables => FALSE,
enablehierarchy => DBMS_XMLSCHEMA.enable_hierarchy_none);
END;
/
We can check the schema details using the USER_XML_SCHEMAS view.
SELECT schema_url FROM user_xml_schemas;
SCHEMA_URL
student.xsd SQL>
Validate XML Document (SCHEMAVALIDATE)
DECLARE
l_xml CLOB; l_xmltype XMLTYPE; BEGIN
l_xml := '<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<MAILS>
<MAIL>
<TO_>STU10</TO_>
<FROM_>STU01</FROM_>
<HEADING_>REMAINDER</HEADING_>
<BODY_>Don't forget the Exam</BODY_>
</MAIL>
<MAIL>
<TO_>STU20</TO_>
<FROM_>STU02</FROM_>
<HEADING_>INVITATION</HEADING_>
<BODY_>Come to my Brother's Marriage</BODY_>
</MAIL>
<MAIL>
<TO_>STU30</TO_>
<FROM_>STU03</FROM_>
<HEADING_>REQUEST</HEADING_>
<BODY_>Please give me a pen</BODY_>
</MAIL>
</MAILS>
l_xmltype := XMLTYPE(l_xml, 'student.xsd'); l_xmltype.schemavalidate;
END;
/
OUTPUT
PL/SQL procedure successfully completed.
SQL>
DECLARE
l_xml CLOB; l_xmltype XMLTYPE; BEGIN
l_xml := '<?xml version="1.0" encoding="UTF-8"?>
<?xml version="1.0" encoding="UTF-8"?>
<MAILS>
<MAIL>
<TO_>STU10</TO_>
<FROM_1>STU01</FROM_>
<HEADING_>REMAINDER</HEADING_>
<BODY_>Don't forget the Exam</BODY_>
</MAIL>
<MAIL>
<TO_>STU20</TO_>
<FROM_>STU02</FROM_>
<HEADING_>INVITATION</HEADING_>
<BODY_>Come to my Brother's Marriage</BODY_>
</MAIL>
<MAIL>
<TO_>STU30</TO_>
<FROM_>STU03</FROM_>
<HEADING_>REQUEST</HEADING_>
<BODY_>Please give me a pen</BODY_>
</MAIL>
</MAILS>
l_xmltype := XMLTYPE(l_xml, 'student.xsd');
l_xmltype.schemavalidate;
END;
/
OUTPUT :
DECLARE
*
ERROR at line 1:
ORA-30937: No schema definition for 'FROM_1' (namespace '##local') in parent '/MAILS/MAIL'
ORA-06512: at "SYS.XMLTYPE", line 354
ORA-06512: at line 10
SQL>
RESULT :
PROGRAM 11 :
DOCUMENT DATABASE
use ABC
db
db.createCollection("Student")
show collections
db.Student.insertMany([{ID:101,Name:"AAA"},{ID:102,Name:"BBB"},{ID:103,Name:"CCC"},{ID
:104,Name:"DDD"},{ID:105,Name:"EEE"}])
db.Student.find()
db.Student.updateOne({Name:"EEE"},{$set:{ID:106}})
db.Student.find()
db.Student.deleteOne({ID:106})
db.Student.find()
db.Student.remove({})
db.Student.find()
db.Student.drop()
show collections
db.dropDatabase()
COLUMN ORIENTED DATABASE
Create keyspace nosql;
desc keyspaces;
use nosql;
desc nosql;
create table Student(ID int primary key, Name text);
desc Student;
Select * from Student;
insert into Student(id,name) values (1,'AAA');
insert into Student(id,name) values (2,'BBB');
insert into Student(id,name) values (3,'CCC');
insert into Student(id,name) values (4,'DDD');
insert into Student(id,name) values (5,'EEE');
select * from Student;
update Student set name='FFF' where id=5;
select * from Student;
delete from Student where id=5;
select * from Student;
truncate Student;
select * from Student;
Desc Student;
OUTPUT :
RESULT :
CONTENT BEYOND SYLLABUS
Ex. No. : 14 Date :
PostgreSQL
AIM :
To write query to create schema table, insert value, update value, delete value and drop table in
PostgreSQL..
DESCRIPTION :
1. Command: Create schema
RESULT :
Thus the query to create schema table, insert value, update value, delete value and drop table in
PostgreSQL has been executed and output was verified.
Ex. No. : 15 Date :
DbVisualizer
AIM :
To create EER diagram and use filter for showing results of a database table using DbVisualizer.
DESCRIPTION :
Creating a schema
To create a new schema:
1. Locate the Schemas node in the Databases tab tree.
2. Open the Create Schema dialog from the right-click menu.
3. Enter all required information (database dependent).
4. Click Execute to create the schema.
● Start DbVisualizer and establish a connection to our database by selecting the appropriate driver,
specifying the connection details, and providing login credentials.
● Once connected, expand the database node in the Database Objects view and navigate to the table
we want to filter.
● Right-click on the table and choose "Open Table" to open the Table Editor.
● In the Table Editor, we'll see the table data displayed in a grid format.
● Look for the "Filter Mode" button in the toolbar. It usually looks like a funnel icon.
● Click on the "Filter Mode" button to enable the filter mode for the table.
3. Define Filters:
● Once the filter mode is enabled, we'll notice that each column header now has a filter icon (usually
a funnel or a small arrow).
● Click on the filter icon of the column we want to apply a filter to. A filter dialog or dropdown will
appear.
● Depending on the column's data type, the available filter options may vary. Common filter options
include:
4. Apply Filters:
● Define our filter criteria within the filter dialog for the selected column.
● Click "OK" or "Apply" to apply the filter.
● We can apply filters to multiple columns simultaneously to perform more complex filtering.
5. Remove Filters:
● To remove a filter and show all data again, click on the filter icon of the filtered column and choose
"Clear Filter."
● If we want to disable the filter mode and display all data again without filters, click on the "Filter
Mode" button in the toolbar to turn it off.
OUTPUT :
Generating Database EER Diagram
Using Filter for Database Table
RESULT :
Thus creating EER diagram and using filter for showing results of a database table using DbVisualizer
has been written, executed successfully and the output was verified.