Database Management System: Oracle 8.x
Database Management System: Oracle 8.x
Oracle 8.x
Data Types
Char( size) : max( 255 character)
:Padded with spaces
Varchar(size): max(2000 char)
:not padded
Number(p,s): p=38 digits
s=125 zeros
Date: DD-MON-YY
Long: variable length char string up to 2GB
(Substring cannot be applied)
RAW:picture or images upto 255 bytes
LONGRAW: 2GB
Creating a Table
Table created
Retrieving data from table
(DML statements)
SQL> select *From < table Name>;
DEFAULT: Ascending
Continue ……..
Select < attribute list>
From <table name>
Where < condition> (optional)
Order By attribute_name;
Default in ascending order.
Select < attribute list>
From <table name>
Where < condition> (optional)
Order By attribute_name desc;
Example
SQL> select empno,ename
From emp
Where deptno=5
Order by empno;
Default Ascending
AND
OR
NOT
AND Operator
SQL> select <attribute list>
from <table name>
where condition1 and condition2;
Having ( condition)
Group By and Having
SQL> select aggregate_function( column name)
from <table name>
group by <column name>
having <condition>;
SQL> select sum(salary),deptno
from emp
group by deptno
having salary>1000;
Constraints
1. Column Level
( if apply on single column)
2. Table Level
( if apply on more than one column)
Table Level
2. UNIQUE
attribute value will be unique but at
least one time it will accept null value.
NOT NULL
SQL> create table emp(
empno varchar(10) NOT NULL,
ename varchar(10)
salary number(10,2)
deptno number(2));
UNIQUE
SQL> create table emp(
empno varchar(10) UNIQUE,
ename varchar(10)
salary number(10,2)
deptno number(2));
Foreign Key
SQL> create table emp(
empno varchar(10) primary key,
ename varchar(10)
salary number(10,2)
deptno number(2)
foreign key (deptno) references dept(deptno));
Check Constraints
SQL> create table emp(
empno varchar(10) primary key,
ename varchar(10)check (ename like ‘a%’),
salary number(10,2),
deptno number(2));
Only ename starting with letter ‘a’ are allowed.
Default Constraints
SQL> create table emp(
empno varchar(10) primary key,
ename varchar(10),
salary number(10,2),
sex varchar(1) default ‘M’,
deptno number(2));
Adding constraints by
Alter Table Command
1. Equi-join