Launch and Use Oracle Tools 1.connect To Your Oracle Database. 2.simple SQL Commands

You might also like

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

CS457

Launch and Use Oracle Tools


1. Connect to your Oracle database.
2. Simple SQL Commands.

Connect Database:
1.Download and install putty.exe.
2.Connect to npusl8.npu.edu
Note: Enter Host Name: npusl8.npu.edu

Click on open button.


Login with your userID and password.
Execute bellow 3 commands:
i. Step 1: bash
ii. Step 2: source /home0/bashrc
iii.

Step 3: sqlplus

After executing above 3 commands enter oracle username: CS457_studentID


Password: changeme
Use command as per below screen shot:

Simple SQL Commands:


1. Create Table:

Syntax: create table table_name (column_name1 datatype1, column_name2,datatype2,......)


2.INSERT Into:
Syntax: Insert into Table_name Values (value1,value2,.....)
3.SELECT:
The SELECT is used to query the database and retrieve data from table.
Syntax: SELECT column1 [, column2, ...] FROM tablename WHERE condition

The conditional clause can include these operators


= Equal
> Greater than
< Less than
>= Greater than or equal
<= Less than or equal
<> Not equal to
SELECT * FROM tablename
returns all the data from the table.
Exercise:
1) Create a table employee with follow columns:
Empno,ename,job,mgr,hiredate,sal,comm,deptno
Create table emp(empno number,ename varchar2(15),job varchar2(15),mgr number,hiredate date,
sal number,comm number,deptno number)
2) Display the structure of the employee table(Hint: Use desc)
3) Insert at least two employee records into employee table.
Hint: Insert into emp values (7934,miller,clerk,7782,23-jan-82,1300,10)
4) Write a query to display just the employee names. (Hint: Select statement)
5) Write a query to display only empno, ename and job of the employees.

6) Write a query to display the employee table(Hint: Use *)


7) Create a table department with the following columns:
deptno, dname, loc
8) Insert at least two records into department table.

You might also like