易截截图软件、单文件、免安装、纯绿色、仅160KB

ORACLE的索引和约束详解

 * 如果某个约束只作用于单独的字段,即可以在字段级定义约束,也可以在表级定义约束,但如果某个约束作用于多个字段, 
必须在表级定义约束 
* 在定义约束时可以通过CONSTRAINT关键字为约束命名,如果没有指定,ORACLE将自动为约束建立默认的名称 
定义primary key约束(单个字段) 
create table employees (empno number(5) primary key,...) 
指定约束名 
create table employees (empno number(5) constraint emp_pk primary key,...) 
定义primary key约束(多个字段,在表级定义约束) 
create table employees 
(empno number(5), 
deptno number(3) not null, 
constraint emp_pk primary key(empno,deptno) 
using index tablespace indx 
storage (initial 64K 
next 64K 


ORACLE自动会为具有PRIMARY KEY约束的字段(主码字段)建立一个唯一索引和一个NOT NULL约束,定义PRIMARY KEY约束时可以为它的索引 
指定存储位置和存储参数 
alter table employees add primary key (empno) 
alter table employees add constraint emp_pk primary key (empno) 
alter table employees add constraint emp_pk primary key (empno,deptno) 
not null约束(只能在字段级定义NOT NULL约束,在同一个表中可以定义多个NOT NULL约束) 
alter table employees modify deptno not null/null 
unique约束 
create table employees 
( empno number(5), 
ename varchar2(15), 
phone varchar2(15), 
email varchar2(30) unique, 
deptno number(3) not null, 
constraint emp_ename_phone_uk unique (ename,phone) 

alter table employees 
add constraint emp_uk unique(ename,phone) 
using index tablespace indx 
定义了UNIQUE约束的字段中不能包含重复值,可以为一个或多个字段定义UNIQUE约束,因此,UNIQUE即可以在字段级也可以在表级定义, 
在UNIQUED约束的字段上可以包含空值. 
foreign key约束 
* 定义为FOREIGN KEY约束的字段中只能包含相应的其它表中的引用码字段的值或者NULL值 
* 可以为一个或者多个字段的组合定义FOREIGN KEY约束 
* 定义了FOREIGN KEY约束的外部码字段和相


相关文档:

ORACLE RBA(redo byte address)

Redo Byte Address (RBA)
Recent entries in the redo thread of an Oracle instance are addressed using a 3-part redo byte address, or RBA. An RBA is comprised of
the log file sequence number (4 bytes)
the log file block number (4 bytes)
the byte offset into the block at which the redo record sta ......

Oracle表空间和数据文件的常用操作

表空间资料查询
SELECT tablespace_name, block_size, extent_management, segment_space_management from dba_tablespaces;
配和
SELECT tablespace_name, initial_extent, next_extent, max_extents, pct_increase, min_extlen from dba_tablespaces;
配合
SEL ......

oracle 基础 控制机构+赋值

   --变量赋值
   declare
   identity :=0;
   a varchar2(59,0);
   b varchar2(50):='abc';
   a :='cba';
  
   -- 控制语句
   ----------------------------------
   if a>b then
   ......

oracle 数据库里面块大小的优缺点

 大块,优点:
1、顺序读、索引读性能好
因为大块容纳的行相对小块数据
多,在进行全表扫描的时候,或者索引扫描的时候,所需要的物理读、逻辑读都要少。
它也能减小索引的树高。对于索引访问
的性能有所提高。
2、大块能容纳比较大的行
容纳大行个人理解,一定程度上可以避免行迁移、行链接。减小大行的读取块 ......

Oracle 9i中的flash back 查询


语法:
select *
from [TABLE] as of timestamp
to_timestamp('时间', ’时间格式')
 
作用:
查询某个时间点的数据,在这个时间点之后,数据更改已经提交了。
可以用来更正用户对数据的误操作
可以用来获取数据的更改情况,比如频率等
 
原理:
当数据update或delete时,原来的数据 ......
© 2009 ej38.com All Rights Reserved. 关于E健网联系我们 | 站点地图 | 赣ICP备09004571号