Академический Документы
Профессиональный Документы
Культура Документы
Overview
Oracle terms
Schema logical collection of users
objects
Tablespace logical space used for
storage
Datafile physical file used for storage
Extent group of contiguous blocks
Block unit of physical storage
Oracle Architecture
database vs. instance
Database Instance
Disk Memory
MySQL
Three files per table
Permissions based on user, database, and host
Oracle
Many files
Many roles/permissions possible
The Oracle Data Dictionary
inserting apostrophes
INSERT INTO emp (name) VALUES (ONeill);
Example:
select to_char (adate, dd-mon-yy hh24:mi:ss)
TO_CHAR(ADATE, DD-MON-YY:HH24:MI:SS)
17-feb-00 23:41:50
SELECT *
FROM emp, dept
WHERE emp.deptno(+)=dept.id;
Oracle SQL functions
Upper(), lower()
Substr(), replace(), rtrim(), concat()
Length()
Floor(), sqrt(), min(), max(), stddev()
decode()
Sort of like an If/Then statement
Decode(gender,0,Male,1,Female,Unknown)
Oracle error messages
Divided into groups by first three letters
(e.g. ORA or TNS)
Number gives more information about
error
Several messages may be related to
only one problem
oerr facility
Constraints
Primary key
Foreign key
Unique, not null
Check CREATE TABLE test (
id NUMBER(2),
col2 VARCHAR2(2),
col3 VARCHAR2(3),
CONSTRAINT test_pk PRIMARY KEY(id),
CONSTRAINT col3_ck CHECK (col3 IN ('yes','no'))
);
NAME T SEARCH_CONDITION
--------------- - -------------------------
COL3_CK C col3 IN ('yes','no')
TEST_PK P
Constraints
Oracle naming of constraints is NOT intuitive!
TRIGGER_NAME
------------------------------
AFTER_INS_UPD_ON_EMP
end;
The above trigger was created with the following statement:
1 GREEN MED
2 RED MED
3 RED SMALL
4 BLUE LARGE
Part number 1 2 3 4