Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Pratical Program

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 24

FONT APPLICATION

Public Class Form1


Private Sub BOLD_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles BOLD.Click
RichTextBox1.SelectionFont = New Drawing.Font(RichTextBox1.SelectionFont,
Drawing.FontStyle.Bold)
End Sub

Private Sub ITAIC_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ITAIC.Click
RichTextBox1.SelectionFont = New Drawing.Font(RichTextBox1.SelectionFont,
Drawing.FontStyle.Italic)
End Sub

Private Sub UNDERLINE_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles UNDERLINE.Click
RichTextBox1.SelectionFont = New Drawing.Font(RichTextBox1.SelectionFont,
Drawing.FontStyle.Underline)
End Sub

Private Sub STRIKEOUT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles STRIKEOUT.Click
RichTextBox1.SelectionFont = New Drawing.Font(RichTextBox1.SelectionFont,
Drawing.FontStyle.Strikeout)
End Sub

Private Sub REGULAR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles REGULAR.Click
RichTextBox1.SelectionFont = New Drawing.Font(RichTextBox1.SelectionFont,
Drawing.FontStyle.Regular)
End Sub

Private Sub LEFT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles LEFT.Click
RichTextBox1.SelectionAlignment = HorizontalAlignment.Left
End Sub

Private Sub RIGHT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RIGHT.Click
RichTextBox1.SelectionAlignment = HorizontalAlignment.Right
End Sub

Private Sub CENTER_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CENTER.Click
RichTextBox1.SelectionAlignment = HorizontalAlignment.Center
End Sub

Private Sub COLOR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles COLOR.Click
ColorDialog1.ShowDialog()
RichTextBox1.SelectionColor = ColorDialog1.Color
End Sub

Private Sub STYLE_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles STYLE.Click
FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font

End Sub

Private Sub CLEAR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CLEAR.Click
RichTextBox1.Clear()
End Sub

Private Sub EXIT_EXIT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles EXIT_EXIT.Click
End
End Sub
End Class

CALCULATOR

Public Class Form1

Dim RESULT As Double = 0


Private Sub ONE_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles ONE.Click
TextBox1.Text += ONE.Text
End Sub

Private Sub TWO_Click(ByVal sender As Object, ByVal e As System.EventArgs)


Handles TWO.Click
TextBox1.Text += TWO.Text
End Sub

Private Sub THREE_Click(ByVal sender As Object, ByVal e As


System.EventArgs) Handles THREE.Click
TextBox1.Text += THREE.Text
End Sub

Private Sub FOUR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles FOUR.Click
TextBox1.Text += FOUR.Text
End Sub

Private Sub FIVE_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles FIVE.Click
TextBox1.Text += FIVE.Text
End Sub

Private Sub SIX_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles SIX.Click
TextBox1.Text += SIX.Text
End Sub

Private Sub SEVEN_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles SEVEN.Click
TextBox1.Text += SEVEN.Text
End Sub

Private Sub EIGHT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles EIGHT.Click
TextBox1.Text += EIGHT.Text
End Sub

Private Sub NINE_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles NINE.Click
TextBox1.Text += NINE.Text
End Sub

Private Sub DOT_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles DOT.Click
TextBox1.Text += DOT.Text
End Sub

Private Sub ZERO_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button0.Click
TextBox1.Text += Button0.Text
End Sub

Private Sub DBLZERO_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button00.Click
TextBox1.Text += Button00.Text
End Sub

Private Sub PLUS_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ADD.Click
TextBox1.Text += ADD.Text
End Sub

Private Sub MINUS_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles SUT.Click
TextBox1.Text += SUT.Text
End Sub

Private Sub MUL_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles MUL.Click
TextBox1.Text += MUL.Text
End Sub

Private Sub DIV_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles DIV.Click
TextBox1.Text += DIV.Text
End Sub

Private Sub OPEN_PARAN_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button17.Click
TextBox1.Text += Button17.Text
End Sub

Private Sub CLOSE_PARAN_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button18.Click
TextBox1.Text += Button18.Text
End Sub

Private Sub EQUALTO_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles EQ.Click
Dim TEMP, OPE As String
TEMP = TextBox1.Text
Dim LEN As Double
LEN = TEMP.Length - 1
OPE = TEMP.Chars(LEN)
If OPE = "+" Or OPE = "-" Or OPE = "*" Or OPE = "/" Or OPE = "(" Then
MsgBox("SYNTAX ERROR")
Else
RESULT = New DataTable().Compute(TEMP, Nothing)
TextBox1.Text = RESULT
End If
End Sub

Private Sub CLEAR_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CLEAR.Click
TextBox1.Text = ""
End Sub
End Class
DIGITAL CLOCK

Public Class Form1

Dim hr, mins, sec, msec As Integer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Timer1.Start()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
Timer1.Stop()
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
TextBox1.Text = ""
hr = 0
mins = 0
sec = 0
msec = 0
Timer1.Start()

End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
h: hr = InputBox("Enter the hour value:")
If hr >= 24 Then
MsgBox("Enter the valid value:")
GoTo h
Else
m: mins = InputBox("Enter the minute value:")
If mins >= 60 Then
MsgBox("Enter valid value")
GoTo m
Else
s: sec = InputBox("Enter the second value:")
If sec >= 60 Then
MsgBox("Enter valid value")
GoTo s
Else
ms: msec = InputBox("Enter the millisecond value:")
If msec >= 100 Then
MsgBox("Enter valid value")
GoTo ms
End If
End If
End If
End If
Timer1.Start()
End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
End
End Sub

Private Sub Timer1_Tick(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Timer1.Tick
msec = msec + 1
If msec >= 100 Then
msec = 0
sec = sec + 1
If sec >= 60 Then
sec = 0
mins = mins + 1
If mins >= 60 Then
mins = 0
hr = hr + 1
If hr >= 24 Then
hr = 0
mins = 0
sec = 0
msec = 0
End If
End If
End If
End If
TextBox1.Text = hr & " : " & mins & " : " & sec & " : " & msec
End Sub
End Class

NOTEPAD

Public Class Form1


Dim temp, str As String
Private Sub NewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles NewToolStripMenuItem.Click
RichTextBox1.Text = ""
RichTextBox1.BackColor = Color.White
RichTextBox1.ForeColor = Color.Black
End Sub

Private Sub OpenToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles OpenToolStripMenuItem.Click
OpenFileDialog1.ShowDialog()
RichTextBox1.LoadFile(OpenFileDialog1.FileName,
RichTextBoxStreamType.PlainText)
End Sub

Private Sub SaveToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles SaveToolStripMenuItem1.Click
SaveFileDialog1.ShowDialog()
RichTextBox1.SaveFile(SaveFileDialog1.FileName,
RichTextBoxStreamType.PlainText)
End Sub

Private Sub SaveAsToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles SaveAsToolStripMenuItem.Click
SaveFileDialog1.ShowDialog()
RichTextBox1.SaveFile(SaveFileDialog1.FileName,
RichTextBoxStreamType.PlainText)
End Sub

Private Sub PrintToolStripMenuItem2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles PrintToolStripMenuItem8.Click
PrintDialog1.ShowDialog()
End Sub

Private Sub PrintPreviewToolStripMenuItem_Click(ByVal sender As System.Object, ByVal


e As System.EventArgs) Handles PrintPreviewToolStripMenuItem.Click
PrintPreviewDialog1.ShowDialog()
End Sub

Private Sub ExitToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles ExitToolStripMenuItem.Click
End
End Sub

Private Sub CutToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CutToolStripMenuItem.Click
RichTextBox1.Cut()
End Sub

Private Sub CopyToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles CopyToolStripMenuItem.Click
RichTextBox1.Copy()
End Sub

Private Sub PasteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles PasteToolStripMenuItem.Click
RichTextBox1.Paste()
End Sub

Private Sub RedoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles RedoToolStripMenuItem1.Click
RichTextBox1.Redo()
End Sub

Private Sub UndoToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles UndoToolStripMenuItem.Click
RichTextBox1.Undo()
End Sub

Private Sub SelectAllToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles SToolStripMenuItem.Click
RichTextBox1.SelectAll()
End Sub

Private Sub DeleteToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles DeleteToolStripMenuItem.Click
RichTextBox1.SelectedText = ""
End Sub

Private Sub FindToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles FindToolStripMenuItem1.Click
str = InputBox("Enter the string to find:")
temp = RichTextBox1.Find(str, 0, Len(RichTextBox1.Text), 1)
If temp >= 0 Then
MsgBox("The string is found")
Else
MsgBox("The string is not found")
End If
End Sub

Private Sub ReplaceToolStripMenuItem1_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles ReplaceToolStripMenuItem1.Click
str = InputBox("Enter the string to replace:")
RichTextBox1.SelectedText = str
End Sub

Private Sub FontToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles FontToolStripMenuItem.Click
FontDialog1.ShowDialog()
RichTextBox1.SelectionFont = FontDialog1.Font
End Sub

Private Sub ForeColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles ForeColorToolStripMenuItem1.Click
ColorDialog1.ShowDialog()
RichTextBox1.SelectionColor = ColorDialog1.Color
End Sub

Private Sub BackColorToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e


As System.EventArgs) Handles BackToolStripMenuItem.Click
ColorDialog1.ShowDialog()
RichTextBox1.BackColor = ColorDialog1.Color
End Sub
End Class

STUDENT DETAILS

Public Class Form1


Dim cn As New OleDb.OleDbConnection
Dim cmd As New OleDb.OleDbCommand
Dim cnstr, sql As String

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button1.Click
Dim TOT As Integer
Dim AVG As Double
Dim RES As String
TOT = Val(TextBox4.Text) + (TextBox5.Text) + (TextBox6.Text) + (TextBox7.Text)
TextBox8.Text = TOT
AVG = TOT / 4
TextBox9.Text = AVG
If (Val(TextBox4.Text) >= 40 And Val(TextBox5.Text) >= 40 And (TextBox6.Text) >=
40 And (TextBox7.Text) >= 40) Then
RES = "PASS"
Else
RES = "FAIL"
End If
TextBox10.Text = RES
If AVG >= 90 Then
TextBox11.Text = "O"
ElseIf AVG >= 80 Then
TextBox11.Text = "A"
ElseIf AVG >= 70 Then
TextBox11.Text = "B"
ElseIf AVG >= 60 Then
TextBox11.Text = "C"
ElseIf AVG >= 50 Then
TextBox11.Text = "D"
ElseIf AVG >= 40 Then
TextBox11.Text = "E"
Else
TextBox11.Text = "F"

End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button4.Click
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""

End Sub

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button5.Click
End
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs)


Handles MyBase.Load
cnstr = "Provider=MSDAORA;Data Source=orcl;User ID=l3221it055;password=kasc"
cn = New OleDb.OleDbConnection(cnstr)

End Sub

Private Sub ComboBox1_GotFocus(ByVal sender As Object, ByVal e As


System.EventArgs) Handles ComboBox1.GotFocus
ComboBox1.Items.Clear()
cn.Open()
sql = "select reg_no from student_details"
Dim ocmd As New OleDb.OleDbCommand(sql, cn)
Dim odareader As OleDb.OleDbDataReader = ocmd.ExecuteReader
While odareader.Read
ComboBox1.Items.Add(odareader.GetValue(0).ToString())
End While
odareader.Close()
cn.Close()
End Sub

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As


System.EventArgs) Handles ComboBox1.SelectedIndexChanged
cn.Open()
sql = "select * from student_details where reg_no='" + ComboBox1.SelectedItem + "'"
Dim ocmd As New OleDb.OleDbCommand(sql, cn)
Dim odareader As OleDb.OleDbDataReader = ocmd.ExecuteReader
While odareader.Read
TextBox1.Text = odareader.GetValue(0).ToString()
TextBox2.Text = odareader.GetValue(1).ToString()
TextBox3.Text = odareader.GetValue(2).ToString()
TextBox4.Text = odareader.GetValue(3).ToString()
TextBox5.Text = odareader.GetValue(4).ToString()
TextBox6.Text = odareader.GetValue(5).ToString()
TextBox7.Text = odareader.GetValue(6).ToString()
TextBox8.Text = odareader.GetValue(7).ToString()
TextBox9.Text = odareader.GetValue(8).ToString()
TextBox10.Text = odareader.GetValue(9).ToString()
TextBox11.Text = odareader.GetValue(10).ToString()

End While
odareader.Close()
cn.Close()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button2.Click
cn.Open()
sql = "insert into student_details values('" + TextBox1.Text + "','" + TextBox2.Text +
"','" + TextBox3.Text + "','" + TextBox4.Text + "','" + TextBox5.Text + "','" + TextBox6.Text
+ "','" + TextBox7.Text + "','" + TextBox8.Text + "','" + TextBox9.Text + "','" +
TextBox10.Text + "','" + TextBox11.Text + "')"
cmd = New OleDb.OleDbCommand(sql, cn)
cmd.ExecuteNonQuery()
cn.Close()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""
MsgBox("Record saved")

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As


System.EventArgs) Handles Button3.Click
cn.Open()
sql = "delete into student_details where reg_no='" + TextBox1.Text + "'"
cmd = New OleDb.OleDbCommand(sql, cn)
cmd.ExecuteNonQuery()
cn.Close()
TextBox1.Text = ""
TextBox2.Text = ""
TextBox3.Text = ""
TextBox4.Text = ""
TextBox5.Text = ""
TextBox6.Text = ""
TextBox7.Text = ""
TextBox8.Text = ""
TextBox9.Text = ""
TextBox10.Text = ""
TextBox11.Text = ""

MsgBox("Record deleted")

End Sub
End Class

FACULTY

FACULTY
`````````

SQL> desc faculty;


Name Null? Type
----------------------------------------- -------- ----------------------------
F_ID NOT NULL NUMBER(3)
F_NAME VARCHAR2(15)
DEPT VARCHAR2(10)
DESIG VARCHAR2(10)
SALARY NUMBER(5)

SQL> select *from faculty;

F_ID F_NAME DEPT DESIG SALARY


---------- --------------- ---------- ---------- ----------
1 BALZ IT HOD 35000
2 SIVA CT HOD 30000
3 ASH CS HOD 25000
4 KISHORE IT ASST.PROF 25000
5 SIBI IT ASST.PROF 25000
6 RAM CT ASST.PROF 15000
7 KARTHI CS ASST.PROF 10000

7 rows selected.

SQL> insert into faculty values (8,'aadhi','CT','CEO',60000);

1 row created.

SQL> select *from faculty;

F_ID F_NAME DEPT DESIG SALARY


---------- --------------- ---------- ---------- ----------
1 BALZ IT HOD 35000
2 SIVA CT HOD 30000
3 ASH CS HOD 25000
4 KISHORE IT ASST.PROF 25000
5 SIBI IT ASST.PROF 25000
6 RAM CT ASST.PROF 15000
7 KARTHI CS ASST.PROF 10000
8 aadhi CT CEO 60000

8 rows selected.

SQL> select length(f_name) from faculty;

LENGTH(F_NAME)
--------------
4
4
3
7
4
3
6
5

8 rows selected.

SQL> select upper(f_name),lower(dept),initcap(desig) from faculty;


UPPER(F_NAME) LOWER(DEPT INITCAP(DE
--------------- ---------- ----------
BALZ it Hod
SIVA ct Hod
ASH cs Hod
KISHORE it Asst.Prof
SIBI it Asst.Prof
RAM ct Asst.Prof
KARTHI cs Asst.Prof
AADHI ct Ceo

8 rows selected.

SQL> select substr(f_name,0,3) from faculty;

SUB
---
BAL
SIV
ASH
KIS
SIB
RAM
KAR
aad

8 rows selected.
SQL> select replace(dept,'I','C') FROM FACULTY;

REPLACE(DE
----------
CT
CT
CS
CT
CT
CT
CS
CT

8 rows selected.

SQL> select concat(f_id,f_name) from faculty;

CONCAT(F_ID,F_NAME)
-------------------------------------------------------
1BALZ
2SIVA
3ASH
4KISHORE
5SIBI
6RAM
7KARTHI
8aadhi
8 rows selected.

SQL>

SQL> SELECT SUM(SALARY) FROM FACULTY;

SUM(SALARY)
-----------
225000

SQL>
SQL> SELECT AVG(SALARY) FROM FACULTY;

AVG(SALARY)
-----------
28125

SQL> SELECT MAX(SALARY) FROM FACULTY;

MAX(SALARY)
-----------
60000

SQL> SELECT MIN(SALARY) FROM FACULTY;

MIN(SALARY)
-----------
10000
SQL> SELECT DISTINCT DEPT,COUNT(DEPT) FROM FACULTY GROUP BY
DEPT;

DEPT COUNT(DEPT)
---------- -----------
IT 3
CS 2
CT 3

SQL>

STUDENT TABLE

STUDENT TABLE
```````````````

(i) Table Creation


SQL> create table student618(reg_no number(3) primary key, stud_name varchar2(20), class
varchar2(10), dept varchar2(10), college varchar2(10));
Table created.

SQL> desc student618


Name Null? Type
----------------------------------------- -------- ----------------------------
REG_NO NOT NULL NUMBER(3)
STUD_NAME VARCHAR2(20)
CLASS VARCHAR2(10)
DEPT VARCHAR2(10)
COLLEGE VARCHAR2(10)

(ii) Table Alteration


SQL> alter table student618 add mark number(3);
Table altered.
SQL> desc student618
Name Null? Type
----------------------------------------- -------- ----------------------------
REG_NO NOT NULL NUMBER(3)
STUD_NAME VARCHAR2(20)
CLASS VARCHAR2(10)
DEPT VARCHAR2(10)
COLLEGE VARCHAR2(10)
MARK NUMBER(3)
Rows Insertion
SQL> insert into student618 values(&num,'&name','&class','&dept','&college',&mark);
Enter value for num: 101
Enter value for name: JOHN
Enter value for class: II IT
Enter value for dept: IT
Enter value for college: KASC
Enter value for mark: 78
old 1: insert into student618 values(&num,'&name','&class','&dept','&college',&mark)
new 1: insert into student618 values(101,'JOHN','II IT','IT','KASC',78)
1 row created.

SQL> /
Enter value for num: 102
Enter value for name: PETER
Enter value for class: III IT
Enter value for dept: IT
Enter value for college: KASC
Enter value for mark: 78
old 1: insert into student618 values(&num,'&name','&class','&dept','&college',&mark)
new 1: insert into student618 values(102,'PETER','III IT','IT','KASC',78)
1 row created.

SQL> /
Enter value for num: 103
Enter value for name: DAVID
Enter value for class: II CS
Enter value for dept: CS
Enter value for college: KASC
Enter value for mark: 85
old 1: insert into student618 values(&num,'&name','&class','&dept','&college',&mark)
new 1: insert into student618 values(103,'DAVID','II CS','CS','KASC',85)
1 row created.

SQL> /
Enter value for num: 104
Enter value for name: JAMES
Enter value for class: I CT
Enter value for dept: CT
Enter value for college: KASC
Enter value for mark: 85
old 1: insert into student618 values(&num,'&name','&class','&dept','&college',&mark)
new 1: insert into student618 values(104,'JAMES','I CT','CT','KASC',85)
1 row created.

SQL> /
Enter value for num: 105
Enter value for name: CHARLES
Enter value for class: I IT
Enter value for dept: IT
Enter value for college: KASC
Enter value for mark: 82
old 1: insert into student618 values(&num,'&name','&class','&dept','&college',&mark)
new 1: insert into student618 values(105,'CHARLES','I IT','IT','KASC',82)
1 row created.

SQL> SELECT * FROM STUDENT618;


REG_NO STUD_NAME CLASS DEPT COLLEGE MARK
---------- -------------------- ---------- ---------- ---------- ----------
101 JOHN II IT IT KASC 78
102 PETER III IT IT KASC 78
103 DAVID II CS CS KASC 85
104 JAMES I CT CT KASC 85
105 CHARLES I IT IT KASC 82

(iii) Display distinct mark


SQL> SELECT DISTINCT MARK FROM STUDENT618;
MARK
----------
78
85
82

(iv) Retrieve data using WHERE Clause


SQL> SELECT * FROM STUDENT618 WHERE MARK>80;
REG_NO STUD_NAME CLASS DEPT COLLEGE MARK
---------- -------------------- ---------- ---------- ---------- ----------
103 DAVID II CS CS KASC 85
104 JAMES I CT CT KASC 85
105 CHARLES I IT IT KASC 82

SQL> SELECT * FROM STUDENT618 WHERE DEPT='CS' AND MARK>90;

no rows selected

SQL> SELECT * FROM STUDENT618 WHERE DEPT='CS' OR MARK>90;

REG_NO STUD_NAME CLASS DEPT COLLEGE MARK


---------- -------------------- ---------- ---------- ---------- ----------
103 DAVID II CS CS KASC 85
SQL> SELECT * FROM STUDENT618 WHERE REG_NO BETWEEN 101 AND 103;

REG_NO STUD_NAME CLASS DEPT COLLEGE MARK


---------- -------------------- ---------- ---------- ---------- ----------
101 JOHN II IT IT KASC 78
102 PETER III IT IT KASC 78
103 DAVID II CS CS KASC 85

JOIN OPERATIONS
``````````````````

SQL> CREATE TABLE EMPLOYEE(EMP_ID NUMBER(3) PRIMARY KEY,


EMP_NAME VARCHAR2(20), PHONE NUMBER(10), SALARY NUMBER(8));
Table created.

SQL> DESC EMPLOYEE


Name Null? Type
----------------------------------------- -------- ----------------------------
EMP_ID NOT NULL NUMBER(3)
EMP_NAME VARCHAR2(20)
PHONE NUMBER(10)
SALARY NUMBER(8)

SQL> CREATE TABLE DEPARTMENT(DEPT_ID NUMBER(3), DEPT_NAME


VARCHAR2(10), EMP_ID NUMBER(3) REFERENCES EMPLOYEE(EMP_ID),
DESIGNATION VARCHAR2(15));
Table created.

SQL> DESC DEPARTMENT


Name Null? Type
----------------------------------------- -------- ----------------------------
DEPT_ID NUMBER(3)
DEPT_NAME VARCHAR2(10)
EMP_ID NUMBER(3)
DESIGNATION VARCHAR2(15)
SQL> INSERT INTO EMPLOYEE VALUES(101,'AAA',3546787858,25000);
1 row created.

SQL> INSERT INTO EMPLOYEE VALUES(102,'BBB',8765432109,32000);


1 row created.

SQL> INSERT INTO EMPLOYEE VALUES(103,'CCC',7654328901,20000);


1 row created.
SQL> INSERT INTO EMPLOYEE VALUES(104,'DDD',9870642514,32000);
1 row created.

SQL> INSERT INTO EMPLOYEE VALUES(105,'EEE',6389726410,28000);


1 row created.

SQL> INSERT INTO EMPLOYEE VALUES(106,'FFF',5674328901,38000);


1 row created.

SQL> SELECT * FROM EMPLOYEE;


EMP_ID EMP_NAME PHONE SALARY
---------- -------------------- ---------- ----------------------------
101 AAA 3546787858 25000
102 BBB 8765432109 32000
103 CCC 7654328901 20000
104 DDD 9870642514 32000
105 EEE 6389726410 28000
106 FFF 5674328901 38000
6 rows selected.

SQL> INSERT INTO DEPARTMENT VALUES(1,'PRODUCTION',101,'MANAGER');


1 row created.

SQL> INSERT INTO DEPARTMENT VALUES(1,'PRODUCTION',102,'SUPERVISOR');


1 row created.

SQL> INSERT INTO DEPARTMENT VALUES(2,'SALES',103,'MANAGER');


1 row created.

SQL> INSERT INTO DEPARTMENT VALUES(3,'SERVICE',104,'SUPERVISOR');


1 row created.

SQL> INSERT INTO DEPARTMENT VALUES(4,'PURCHASE',105,'EXECUTIVE');


1 row created.

SQL> SELECT * FROM DEPARTMENT;


DEPT_ID DEPT_NAME EMP_ID DESIGNATION
---------- ----------------------------------- ---------- ---------------
1 PRODUCTION 101 MANAGER
1 PRODUCTION 102 SUPERVISOR
2 SALES 103 MANAGER
3 SERVICE 104 SUPERVISOR
4 PURCHASE 105 EXECUTIVE
5 rows selected.

(i) EQUIJOIN
SQL> SELECT * FROM EMPLOYEE E, DEPARTMENT D WHERE
E.EMP_ID=D.EMP_ID;

EMP_ID EMP_NAME PHONE SALARY DEPT_ID DEPT_NAME EMP_ID


DESIGNATION
---------- -------------------- ---------- ---------- ---------- ---------- ----------
--------------------------------------------
101 AAA 3546787858 25000 1 PRODUCTION 101
MANAGER
102 BBB 8765432109 32000 1 PRODUCTION 102
SUPERVISOR
103 CCC 7654328901 20000 2 SALES 103 MANAGER
104 DDD 9870642514 32000 3 SERVICE 104 SUPERVISOR
105 EEE 6389726410 28000 4 PURCHASE 105 EXECUTIVE
5 rows selected.

(ii) NONEQUIJOIN
SQL> SELECT * FROM EMPLOYEE E, DEPARTMENT D WHERE E.SALARY
BETWEEN 25000 AND 30000;
EMP_ID EMP_NAME PHONE SALARY DEPT_ID DEPT_NAME EMP_ID
DESIGNATION
---------- -------------------------------------------------- ---------- ---------- ---------- ----------
---------- ---------------
101 AAA 3546787858 25000 1 PRODUCTION 101
MANAGER
101 AAA 3546787858 25000 1 PRODUCTION 102
SUPERVISOR
101 AAA 3546787858 25000 2 SALES 103 MANAGER
101 AAA 3546787858 25000 3 SERVICE 104 SUPERVISOR
101 AAA 3546787858 25000 4 PURCHASE 105
EXECUTIVE
105 EEE 6389726410 28000 1 PRODUCTION 101 MANAGER
105 EEE 6389726410 28000 1 PRODUCTION 102
SUPERVISOR
105 EEE 6389726410 28000 2 SALES 103 MANAGER
105 EEE 6389726410 28000 3 SERVICE 104 SUPERVISOR
105 EEE 6389726410 28000 4 PURCHASE 105 EXECUTIVE
10 rows selected.

(iii) SELF-JOIN
SQL> SELECT * FROM EMPLOYEE E, EMPLOYEE F WHERE E.EMP_ID=104;
EMP_ID EMP_NAME PHONE SALARY EMP_ID EMP_NAME
PHONE SALARY
---------- -------------------------------------------- ---------- ---------- ---------- --------------------
---------- ----------
104 DDD 9870642514 32000 101 AAA 3546787858
25000
104 DDD 9870642514 32000 102 BBB 8765432109
32000
104 DDD 9870642514 32000 103 CCC 7654328901
20000
104 DDD 9870642514 32000 104 DDD 9870642514
32000
104 DDD 9870642514 32000 105 EEE 6389726410
28000
5 rows selected.

(iv) OUTER JOIN


SQL> SELECT * FROM EMPLOYEE E, DEPARTMENT D WHERE
E.EMP_ID=D.EMP_ID(+);
EMP_ID EMP_NAME PHONE SALARY DEPT_ID DEPT_NAME EMP_ID
DESIGNATION
---------- -------------------------------------------------- ---------- ---------- ---------- ----------
---------- ---------------
101 AAA 3546787858 25000 1 PRODUCTION 101
MANAGER
102 BBB 8765432109 32000 1 PRODUCTION 102
SUPERVISOR
103 CCC 7654328901 20000 2 SALES 103 MANAGER
104 DDD 9870642514 32000 3 SERVICE 104 SUPERVISOR
105 EEE 6389726410 28000 4 PURCHASE 105 EXECUTIVE
106 FFF 5674328901 38000
6 rows selected.

You might also like