Oracle
Essentials
Courtesy of
Rahul Tikekar
1. Find location of and
something about compiler errors:
show errors;
2. Datatypes:
3. Creating/deleting/updating
tables
create table Emp
(EID number not null,
EName varchar2(20),
EDOB date,
EDept varchar2(10));
delete Emp
where EID=1;
insert
into Emp values (1, 'Dave Letterman', ’12-Apr-1949’,
'Late Night');
update Emp
set EDOB=’12-Apr-1942’ where EID=1;
4. Adding/dropping/enabling/disabling
constraints: use alter table
alter table Emp
add constraint Emp_PK primary key (EID);
alter table Emp
add constraint Emp_FK1
foreign key (EDept)
references Dept (DeptName) [on delete cascade];
alter table Emp
add constraint Emp_Check1 check (Eage > 15 AND EAge < 85);
5. Sequences
Increment by 1
Start with 101
Nocycle;
6. Changing column titles
Select EID "Employee ID" from Emp;
7. Wildcards: % and _
Select EAge from Emp where EName
like ‘%L_’;
8. Objects: Define type, then
define methods
Create type Emp as object ( …)
9. Looking to see what tables
you have created and the constraints on them
Select table_name from user_tables;
Select constraint_name, table_name, constraint_type,
status from user_constraints;
10. Listing the specification
for a table
Describe Emp;