Thursday, April 29, 2021

Slip2 solution

 SQL>create table client(cno varchar2(10) primary key, cname varchar2(20), address varchar2(20));
 Table Created

SQL>create table sales_order(ordno number(10) primary key, odate date not null , cno varchar2(10) references client(cno) on delete cascade);
Table Created

SQL>insert into client values('CN001','Patil','Pimpri');
1 row created

SQL>insert into client values('CN002','Mr. Roy','Pune');
1 row created

SQL>insert into client values('CN003','Mr. Aarav','Satara');
1 row created

SQL>insert into client values('CN004','Meera','Maval');

1 row created

SQL>insert into client values('CN005','Gouari','Punel');
1 row created

SQL>insert into sales_order values(1,'10-Feb-2018','CN001');
1 row created

SQL>insert into sales_order values(2,'09-Aug-2019','CN001');
1 row created

SQL>insert into sales_order values(3,'15-Aug-2019','CN002');
1 row created

SQL>insert into sales_order values(4,'15-March-2018','CN002');
1 row created

SQL>insert into sales_order values(5,'05-Jan-2018','CN003');
1 row created

SQL>insert into sales_order values(6,'05-Feb-2019','CN003');
1 row created

SQL>insert into sales_order values(7,'25-April-2020','CN004');
1 row created

SQL>insert into sales_order values(8,'9-Feb-2018','CN004');
1 row created

SQL>insert into sales_order values(9,'16-Dec-2018','CN005');
1 row created

SQL>insert into sales_order values(10,'16-July-2018','CN005');
1 row created

Q.1. Add column amount into Sales_order table with data type int.

SQL>alter table sales_order add amount int;
Table altered

SQL>update sales_order set amount=100;
10 rows updated.

Q. 2. Delete the details of the clients whose names start with ‘A’ character.

SQL>delete from client where cname like'A%';
1 row deleted.

Q4. Consider the above tables and execute the following queries:

1. Delete sales order details of client whose name is “Patil” and order date is

“09/08/2019”.

SQL>delete from sales_order where odate="09-Aug-2019' and 
cno in (select cno from client where cname='Patil');

2. Change order date of client_No ‘CN001’ to ‘18/03/2019’.

SQL>update sales_order 
         set odate='18 March 2019'
          where cno='CN001';
1 rows updated

3. Delete all sales_record having order date is before ‘10 /02/2018’.

SQL>delete from sales_order 
          where odate<'10-Feb-2018';
1 row deleted

4. Display date wise sales_order given by clients.

SQL>select odate,ono,amount,cno
          from sales_order 
           order  by odate;
10 rows selected

5. Update the address of client to “Pimpri” whose name is ‘Mr. Roy’.

SQL>update client set address='Pimpri'
         where cname='Mr. Roy';
 1 row updated


No comments:

Post a Comment

Slip 10. Write a jQuery code to make first word of each statement to bold.

  Slip 10. Write a jQuery code to make first word of each statement to bold.  <!DOCTYPE html> <html>   <head>     <scri...