Wa0005.
Wa0005.
Wa0005.
Page
Exp.NO. Date Title of the Experiment Marks Signature
no.
EX.NO: 01
AIM:
DDL COMMANDS:
1. Create
2. Drop
3. Alter
4. Truncate
5. Comment
6. Rename
CREATE A TABLE:
SQL> create table Students (ROLL_NO number(3), NAME varchar(20), SUBJECT varchar(20));
Table created.
1 row created.
1 row created.
SQL> insert into Students(ROLL_NO,NAME,SUBJECT)values(102,'Aashi','OOPs');
1 row created.
ALTER TABLE:
Table altered.
1 row updated.
1 row updated.
SQL> update Students set DEPARTMENT = 'MCA' where ROLL_NO = '102';
1 row updated.
Table altered.
Table altered.
RENAME:
Table altered.
TRUNCATE:
Table truncated.
SQL> select * from student;
Table dropped.
RESULT:
EX.NO: 2
AIM:
To modify a table using Data Manipulation Language (DML).
DML COMMANDS:
1. Insert
2. Update
3. Delete
CREATE TABLE:
Table created.
1. INSERT:
SQL> insert into Customer_table
(CUS_ID,CUS_NAME,PH_NUM)values(500,'ARUNA',8300053166);
1 row created.
1 row created.
1 row created.
2. UPDATE:
Table altered.
SQL> update Customer_Table set AMT_PURCHASED = '5000' where CUS_ID = '500';
1 row updated.
1 row updated.
1 row updated.
1 row deleted.
SQL> select * from Customer_Table;
RESULT:
EX.NO: 3
AIM:
To store and retrieve a table using data through Data Control Language (DCL).
DCL COMMANDS:
1. Grant
2. Revoke
CREATING A TABLE:
SHOW USER:
SQL> show user;
GRANT:
REVOKE:
SQL> connect
Enter password:
RESULT:
EX.NO: 4
AIM:
CREATING A TABLE:
SQL> create table CUS(C_ID number(5) primary key,C_NAME varchar(20) not null,DEPT
varchar(8),DOB date,SALARY number(10));
INSERTING INTO TABLE:
RESULT:
EX.NO: 5
AIM:
JOINS:
1. Inner join
2. Natural join
3. Left outer join
4. Right outer join
5. Full outer join
TABLE 1:
CREATING A TABLE:
SQL> create table emp(E_NO number(5),E_NAME varchar(20));
TABLE 2:
CREATING A TABLE:
SQL> create table emp1(E_NO number(5),E_RANK number(5),PH_NO number(10));
NATURAL JOIN:
SQL> select * from emp left outer join emp1 on emp.E_NO = emp1.E_NO;
SQL> select * from emp full outer join emp1 on emp.E_NO = emp1.E_NO;
GROUP BY FUNCTIONS:
CREATING A TABLE:
SQL> create table book(B_ID number(5),B_NAME varchar(12),AUTHOR_NAME varchar(15),PUB
varchar(10),year number(5),price number(10));
EX.NO: 6
AIM:
To implement a table using simple programs in sql.
CREATING A TABLE:
SQL> create table emp(E_ID int not null,E_NAME varchar(12)not null,AGE int not null,SALARY
number(10));
PROGRAMS:
SQL> declare
2 name varchar(12);
3 salary number;
4 begin
7 dbms_output.put_line('Customer:'||name);
8 dbms_output.put_line('Salary:'||salary);
9 end;
10 /
OUTPUT:
WHILE LOOP:
SQL> declare
2 n number;
3 i number:=0;
4 begin
5 dbms_output.put_line('WHILE LOOP');
6 n:=&n;
7 while i<=n
8 loop
9 dbms_output.put_line(i);
10 i:=i+2;
11 end loop;
12 end;
13 /
old 6: n:=&n;
new 6: n:=7;
OUTPUT:
FOR LOOP:
SQL> declare
2 n number;
3 begin
4 dbms_output.put_line('FOR LOOP');
5 n:=&n;
6 for i in 1..n
7 loop
8 dbms_output.put_line(i);
9 end loop;
10 end;
11 /
old 5: n:=&n;
new 5: n:=8;
OUTPUT:
RESULT:
EX.NO: 7
AIM:
To create a table using functions.
CREATING A TABLE:
SQL> create table emp(e_id int not null,e_name varchar(10)not null,age int not null,salary
number);
SELECT:
SQL> select * from emp;
CREATING A FUNCTION:
SQL> create or replace function func(s number)
2 return number is
3 salary number;
4 begin
7 return salary;
8 end;
9 /
OUTPUT:
CALLING A FUNCTION:
SQL> declare
2 salary number;
3 e_no number;
4 begin
5 e_no := &e_no;
6 salary := func(e_no);
7 dbms_output.put_line('Salary: '||salary);
8 end;
9 /
OUTPUT:
RESULT:
EX.NO: 8
AIM:
CREATING A TABLE:
PROGRAM:
2 p_id varchar2(15);
3 s_name varchar2(15);
4 begin
9 dbms_output.put_line('Product Name:'||s_name);
10 dbms_output.put_line('Product:'||p_id);
11 end;
12 /
OUTPUT:
RESULT:
EX.NO: 9
AIM:
To create a table and implementing triggers.
TABLE 1:
CREATING A TABLE:
TABLE 2:
CREATING A TABLE:
PROGRAM:
CREATING TRIGGER:
SQL> create or replace trigger e_salary
4 begin
5 insert into emp1(e_id,e_name,b_date,e_salary)
6 values(:new.e_id,:new.e_name,sysdate,:new.salary);
7 end;
8 /
OUTPUT:
UPDATE:
SQL> update emp set salary = salary+2500.0 where exp>3 and exp<7;
Date:
Procedure:
4. Write code for inserting, deleting, updating and viewing the records.
//Table creation
//Form design
//Code
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Oracle.DataAccess.Client;
namespace exam
{
public partial class Form1 : Form
{
OracleConnection conn = new OracleConnection("Data Source=XE;User
Id=system;Password=password;");
OracleCommand cmd;
public Form1()
{
InitializeComponent();
}
exam(id,name,gen,dep,yr,sems,sub1,sub2,sub3,tot,cg,rest) values('" +
regno.Text +
"','" + name.Text + "','"+dept.Text+"','"+g+"','"+year.Text+"',
'"+sem.Text+"','"+m1.Text+"','"+m2.Text+"','"+m3.Text+"',
'"+total.Text+"','"+cgpa.Text+"','"+res.Text+"')", conn);
MessageBox.Show("Records Inserted Successfully");
cmd.ExecuteNonQuery();
conn.Close();
}
//Output
//Select
//Insert
//Select
//Delete
//Select
//Report
Result: