oracle基础知识
create table test (names varchar2(12),
dates date,
num int,
dou double);
-- 视图
create or replace view vi_test as
select * from test;
-- 同义词
create or replace synonym aa
for dbusrcard001.aa;
-- 存储过程
create or replace produce dd(v_id in employee.empoy_id%type)
as
begin
end
dd;
-- 函数
create or replace function ee(v_id in employee%rowtype) return varchar(15)
is
var_test varchar2(15);
begin
return var_test;
exception when others then
end
-- 三种触发器的定义
create or replace trigger ff
alter delete
on test
for each row
declare
begin
delete from test;
if sql%rowcount < 0 or sql%rowcount is null then
rais_replaction_err(-20004,"错误")
end if
end
create or replace trigger gg
alter insert
on test
for each row
declare
begin
if :old.names = :new.names then
raise_replaction_err(-2003,"编码重复");
end if
end
create or replace trigger hh
for update
on test
for each row
declare
begin
if updating then
if :old.names <> :new.names then
reaise_replaction_err(-2002,"关键字不能修改")
end if
end if
end
-- 定义游标
declare
cursor aa is
select names,num from test;
begin
for bb in aa
loop
if bb.names = "ORACLE" then
end if
end loop;
end
-- 速度优化,前一语句不后一语句的速度快几十倍
select names,dates
from test,b
where test.names = b.names(+) and
b.names is null and
b.dates > date('2003-01-01','yyyy-mm-dd')
select names,dates
from test
where names not in ( select names
from b
where dates > to_date('2003-01-01','yyyy-mm-dd'))
-- 查找重复记录
select names,num
from test
where rowid != (select max(rowid)
from test b
where b.names = test.names and
b.num = test.num)
-- 查找表TEST中时间最新的前10条记录
select * from (select * from test order by dates desc) where rownum < 11
-- 序列号的产生
create sequence row_id
minvalue 1
maxvalue 8888888888888888888888
start with 1
increment by 1
insert into test values(row_id.nextval,....)
(
EMPNO NUMBER(4) not null,
ENAME VARCHAR2(10),
JOB VARCHAR2(9),
MGR NUMBER(4),
HIREDATE DATE,
SAL NUMBER(7,2),
COMM NUMBER(7,2),
DEPTNO NUMBER(2)
)
tablespace USERS
pctfree 10
initrans 1
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
comment on column EMP.EMPNO
is '雇员编号';
comment on column EMP.ENAME
is '雇员的名称';
comment on column EMP.JOB
is '职位';
comment on column EMP.MGR
is '该员工的上级的编号';
comment on column EMP.HIREDATE
is '入职日期';
comment on column EMP.SAL
is '薪水';
comment on column EMP.COMM
is '奖金';
comment on column EMP.DEPTNO
is '部门编号';
alter table EMP
add constraint PK_EMP primary key (EMPNO)
using index
tablespace USERS
pctfree 10
initrans 2
maxtrans 255
storage
(
initial 64K
minextents 1
maxextents unlimited
);
alter table EMP
add constraint FK_DEPTNO foreign key (DEPTNO)
references DEPT (DEPTNO);
oracle--sign
取数字n的符号,大于0返回1,小于0返回-1,等于0返回0
- SQL> select sign(100),sign(-100),sign(0) from dual;
- SIGN(123) SIGN(-100) SIGN(0)
- --------- ---------- ---------
- 1 -1 0
********************************************************************
decode 用法:
oracle基础知识的更多相关文章
- 图说Oracle基础知识(一)
本文主要对Oralce数据库操作的基础知识进行一下梳理,以便进行归纳总结.适用于未使用过Oracle数据库的读者,或需要学习Oracle数据库方面的基础知识.如有不足之处,还请指正. 关于SQL介绍的 ...
- Oracle基础知识汇总一
Oracle基础知识 以下内容为本人的学习笔记,如需要转载,请声明原文链接 https://www.cnblogs.com/lyh1024/p/16720759.html oracle工具: SQ ...
- Oracle 基础知识入门
前记: 近来项目用到Oracle数据库,大学学了点,后面基本忘记得差不多了,虽然基本语法跟sql 差不多,但是oracle知识是非常多的. 这里简单说点基础知识,希望后面补上更多的关于ORacle知识 ...
- Oracle基础知识笔记(10) 约束
表尽管建立完毕了,可是表中的数据是否合法并不能有所检查,而假设要想针对于表中的数据做一些过滤的话,则能够通过约束完毕,约束的主要功能是保证表中的数据合法性,依照约束的分类,一共同拥有五种约束:非空约束 ...
- 2008-03-18 22:58 oracle基础知识小结
oracle 数据类型: 字段类型 中文说明 限制条件 ...
- oracle基础知识过一遍(原创)
用户.角色.权限.表空间 create tablespace test1_tablespace datafile ‘test1file.dbf’ size 10m; create temporary ...
- oracle 基础知识(七)----动态性能视图
一,动态性能视图介绍 动态性能视图属于数据字典,系统管理员用户 SYS 可以访问它们.在数据库打开和使用时不断进行更新,而且它们的内容主要与性能有关.虽然这些视图很像普通的数据库表,但它们不允许用户直 ...
- oracle 基础知识(三)
一.删除oracle 进入注册表到HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\OracleOraHome91TNSListener Ima ...
- oracle基础知识语法大全
ORACLE支持五种类型的完整性约束NOT NULL (非空)--防止NULL值进入指定的列,在单列基础上定义,默认情况下,ORACLE允许在任何列中有NULL值.CHECK (检查)--检查在约束中 ...
- oracle基础知识及语法
ORACLE支持五种类型的完整性约束 NOT NULL (非空)--防止NULL值进入指定的列,在单列基础上定义,默认情况下,ORACLE允许在任何列中有NULL值. CHECK (检查)--检查在约 ...
随机推荐
- Xamarin.ios——First APP
环境:MAC+Xamarin Studio 先讲讲安装吧,最普遍的方法就是去Xamarin官网,注册个账号,填写信息啥的开始下载,安装.但,在天朝的网络环境下,在下载android模块的东东时,总会下 ...
- java中获取文件或文件夹的路径方法
获取当前类的所在工程路径; 如果不加"/" File f = new File(this.getClass().getResource("").getPath( ...
- 深度技术32位Win7系统Ghost版
深度技术32位Win7系统Ghost版,GhostWin7是指使用Ghost软件做成压缩包的Windows7,俗称克隆版Win7.用克隆版的目的是节省安装时间.本作品在采用微软封装部署技术的基础上,结 ...
- Verilog学习笔记简单功能实现(四)...............译码器和编码器
这里以简单的3-8译码器和8-3编码器为例: module decoder3_8(a,out); :]a; :]out; 'b1<<a;/*把最低位的1左移in位(根据in口输入的值)并赋 ...
- Linux命令速查手册,超详细Linux命令教程
一.常用命令速查 ls cd pwd cat more less tail head cp scp mv mkdir rmdir touch rm ps kill top free clear tre ...
- 事件委托 documentFragment
如果有一个列表页,页面结构是外面一个BODY, 里面有一万个子DIV,每个DIV里面有一些文字,这些文字都不相同.需求是,点击一个DIV,要求弹个alert框,将DIV里的文字显示出来.你会怎么做. ...
- 【转】推荐介绍几款小巧的Web Server程序
原博地址:http://blog.csdn.net/heiyeshuwu/article/details/1753900 偶然看到几个小巧有趣的Web Server程序,觉得有必要拿来分享一下,让大家 ...
- 客观评价C#的优点和缺点
对于C#,coder中可以分为2类:一类是C#死忠,对它赞赏到极点:另一类刚好相反,对它极度排斥. 本文将以全面.客观的方式评价这门语言,特别是语法方面. 其实很多人评价一门语言是带着一种感情色彩的. ...
- bootstrap源码分析之scrollspy(滚动侦听)
源码文件: Scrollspy.js 实现功能 1.当滚动区域内设置的hashkey距离顶点到有效位置时,就关联设置其导航上的指定项2.导航必须是 .nav > li > a 结构,并且a ...
- 安卓 9.png 图片的制作
安卓的九宫格png图片可以自定义拉伸的区域,所以可以很方便的适应不同宽度高度的设备. 9.png格式是很纯正的png格式,与普通的png不同的是9.png格式的图片最外围有一圈1像素的透明区域,或者说 ...