当前位置: 首页 > news >正文

深圳科源建设集团有限公司网站站长工具seo综合

深圳科源建设集团有限公司网站,站长工具seo综合,临潼区建设局网站,做列表的网站一、Oracle数据类型 Orcle数据类型说明类比MySQL数据类型字符型CHAR固定长度的字符类型CHAR字符型VARCHAR2可变长度的字符类型VARCHAR字符型LONG大文本类型,最大2G数值型NUMBER数值类型,整数小数都可以,number(5)表示长度5的整数&#xff0c…

一、Oracle数据类型

Orcle数据类型说明类比MySQL数据类型
字符型CHAR固定长度的字符类型CHAR
字符型VARCHAR2可变长度的字符类型VARCHAR
字符型LONG大文本类型,最大2G
数值型NUMBER数值类型,整数小数都可以,number(5)表示长度5的整数,number(5,2)表示共5位,含2位小数INT存整数,FLOAT、DOUBLE存小数
日期型DATE日期时间型,精确到秒
日期型TIMESTAMP精确到秒的小数点后9位
二进制型CLOB存储字符,最大4G(比LONG更多)LONGTEXT
二进制型BLOB存储图像、声音、视频等数据,最大 4GLONGBLOB

二、PL/SQL

PL/SQL(Procedure Language/SQL)是Oracle对SQL语言的过程化扩展,指在SQL命令语言中增加了过程处理语句(分支、循环等)。
基本语法结构

[declare-- 声明变量
]
begin--代码逻辑
[exception--异常处理
]
end;

2.1 变量

变量声明语法:
变量名 类型(长度)
变量赋值语法:
变量名:=变量值
select into赋值语法(结果必须是一条记录,多条记录和没有记录都会报错):
select 列名 into 变量名 from 表名 where 条件

2.2 属性类型

引用型语法,某个变量的类型不预先指定,而是与查询结果相同
表名.列名%type
举例:

declare v_price number(10,2);v_usenum2 number(10,2);v_usenum t_account.usenum%type;--变量的类型与t_account.num0相同v_num0 t_account.num1%type;
beginv_price:=2.45;select usenum,num0 into v_usenum,v_num0 from t_account -- 把usenum赋给v_usenum,num0赋给v_num0where year='2012' and month='01' and owneruuid=1;v_usenum2:=round(v_usenum/1000,2);
end;

记录型语法,某个变量表示一行
表名%rowtype
举例:

declare v_price number(10,2);v_usenum2 number(10,2);v_account t_account%rowtype;--表示一行记录
beginv_price:=2.45;select * into v_account from t_account where year='2012' and month='01' and owneruuid=1;--把查出来的一行给v_accountv_usenum2:=round(v_account.usenum/1000,2);--v_account是一行记录,用.列名使用对应列的值
end;

2.3 异常

oracle中有如下两个异常:
NO_DATA_FOUND:执行select into,未返回行
TOO_MANY_ROWS:执行select into,结果集超过一行
举例:

declare v_price number(10,2);v_usenum2 number(10,2);v_account t_account%rowtype;--表示一行记录
beginv_price:=2.45;select * into v_account from t_account where year='2012' and month='01' and owneruuid=1;--把查出来的一行给v_accountv_usenum2:=round(v_account.usenum/1000,2);--v_account是一行记录,用.列名使用对应列的值
exceptionwhen NO_DATA_FOUND then DBMS_OUTPUT.putline('select into 未返回数据'); -- 这句话是打印输出,类似python中print()when TOO_MANY_ROWS thenDBMS_OUTPUT.putline('select into 返回多行数据');
end;

2.4 条件判断

基本语法1:
if 条件 then 业务逻辑 end if;
基本语法2:
if 条件 then 业务逻辑 else 业务逻辑 end if;
基本语法3:
if 条件 then 业务逻辑 elsif 条件 then 业务逻辑 else 业务逻辑 end if;

2.5 循环

无条件循环语法(重点):
loop 循环语句 end loop;
举例:

declarev_num number;
beginv_num:=1;loopv_num:=v_num+1;exit when v_num>100;--loop循环中使用exit退出循环--也可以写成:if v_num>100 then exit;end if;end loop;
end;

有条件循环语法:
while 条件 loop 循环语句 end loop;
举例:

declarev_num number;
beginv_num:=1;while v_num<=100loopv_num:=v_num+1;end loop;
end;

for循环语法(重点):
for 变量 in 起始值..终止值 loop 循环语句 end loop;
举例:

beginfor v_num in 1..100  --for循环v_num自动声明,不用声明,是局部变量,只能在loop和end loop中间使用loopDBMS_OUTPUT.putline(v_num);end loop;
end;

2.6 游标

游标存放SQL语句的执行结果,可以理解成结果集,可以对其进行逐行处理。

声明游标语法:
cursor 游标名称 is SQL语句;
使用游标语法:

open 游标名称
loopfetch 游标名称 into 变量exit when 游标名称%notfound
end loop;
close 游标名称

普通游标使用举例:

declarecursor cur_pricetable is select * from t_pricetable where owertypeid = 100;--声明游标v_pricetable t_pricetable%rowtype;
beginopen cur_pricetable;--打开游标loopfetch cur_pricetable into v_pricetable;--提取游标exit when cur_pricetable%notfound;--退出循环游标DBMS_OUTPUT.putline(v_pricetable.price);--打印每一条记录的priceend loop;close cur_pricetable;--关闭游标
end;

带参数游标使用举例:

declarecursor cur_pricetable(v_ownertype number) is select * from t_pricetable where owertypeid = v_ownertype;--声明带参数的游标v_pricetable t_pricetable%rowtype;
beginopen cur_pricetable(100);--打开游标,传入参数100loopfetch cur_pricetable into v_pricetable;--提取游标exit when cur_pricetable%notfound;--退出循环游标DBMS_OUTPUT.putline(v_pricetable.price);--打印每一条记录的priceend loop;close cur_pricetable;--关闭游标
end;

for循环使用游标举例:
自动打开、关闭游标,不用声明变量,也不用fetch,可以直接使用

declarecursor cur_pricetable(v_ownertype number) is select * from t_pricetable where owertypeid = v_ownertype;--声明带参数的游标
beginfor v_pricetable in cur_pricetable(100) --for循环使用游标,变量不需要声明loopDBMS_OUTPUT.putline(v_pricetable.price);--打印每一条记录的priceend loop;
end;

三、存储函数

存储函数也称为自定义函数,接受一个或多个参数,返回一个结果。
函数中使用PL/SQL进行逻辑处理

存储函数创建语法:
语法is的后面与PL/SQL语法的declare后面是一样的

create [or replace] function 函数名称
(参数名称 参数类型,参数名称 参数类型, ...)  -- 这里只写参数类型,不写长度
return 结果变量数据类型  -- 指定返回值的参数类型,不写长度
is -- 声明变量
begin-- 代码逻辑return 结果变量;
[exception-- 异常处理
]
end;

举例:

create or replace function fn_getaddress
(v_id number)    -- 函数的参数是number类型
return varchar2  -- 函数的返回值是varchar2类型
is v_name varchar2(30);
begin--根据传入的v_id查询name,并返回nameselect name into v_name from t_address where id=v_id;return v_name;
end;-- 调用函数查询id=3的地址
select fn_getaddress(3) from dual;
-- 调用函数查询addressid对应的地址,不用再进行表关联
select id,name,fn_getaddress(addressid) from t_owners;

四、存储过程

存储函数和存储过程的区别:

  1. 存储函数只能返回一个值,存储过程可以传出多个值(返回多个值)
  2. 存储函数可以直接在select语句中使用,而存储过程不能
  3. 存储函数一般封装一个查询结果,存储过程一般封装一段事务代码

存储过程创建语法:
相比存储函数,把function换成了procedure,且没有了返回值

create [or replace] procedure 存储过程名称
(参数名称 参数类型,参数名称 参数类型, ...)  -- 这里只写参数类型,不写长度,参数可以传入,也可以传出
is-- 声明变量
begin-- 代码逻辑
[exception-- 异常处理
]
end;

过程参数的三种模式:
IN 传入参数(默认)
OUT 传出参数,主要用于返回程序运行结果
IN OUT 传入传出参数

不带传出参数的存储过程举例:

create or replace procedure pro_students_add
(
v_id number,
v_name varchar2
)
is 
begin insert into t_students values(v_id,v_name);commit;
end;-- 调用存储过程
call pro_students_add(10,"啦啦啦");

带传出参数的存储过程举例:

create or replace procedure pro_students_add
(
v_id number,
v_name varchar2,
v_stuid out number --声明一个传出参数
)
is 
begin insert into t_students values(v_id,v_name);commit;-- 对传出参数赋值select id into v_stuid from t_students where id = v_id;
end;-- 调用传出参数的存储过程
declarev_stuid number; -- 声明一个变量,用来接收存储过程的传出参数
beginpro_students_add(10,"啦啦啦",v_stuid); -- 执行完该语句后,v_stuid就有值了,后面可以直接用DBMS_OUTPUT.putline(v_stuid);
end;

五、触发器

触发器是基于某一张表的增删改操作的,在对应的增删改操作执行之前/之后,执行一段PL/SQL代码
触发器分类:
前置触发器,在对应语句之前执行
后置触发器,在对应语句之后执行
行级触发器,每操作一条记录就执行一次触发器(一般都是行级触发器)
语句级触发器,不管操作多少条记录,一个SQL语句只对应执行一次触发器
创建触发器语法:

create [or replace] trigger 触发器名before|after[delete][[or] insert][[or] update [of 列名]]on 表名[for each row][when(条件)] -- for each row表名该触发器是行级触发器
declare
beginPL/SQLend;

触发器中:old和:new所代表的值:

触发语句:old:new
Insert所有字段都是空(null)将要插入的数据
update更新前该行的值更新后该行的值
delete删除以前该行的值所有字段都是空(null)

后置触发器举例:

-- 创建日志表,记录业务名称修改前和修改后的值
create table t_owners_log(
updatetime date,
ownerid number,
oldname varchar2(30),
newname varchar2(30)
);create or replace trigger tri_owners_log
after
update of name  
on t_owners     -- 当t_owners.name被update之后触发该触发器
for each row    -- 行级触发器
declarebegininsert into t_owners_log values(sysdate,:new.id,:old.name,:new.name);\-- 注意触发器里不用commit,会自动commit,如果是存储过程则需要commit
end;

六、视图、物化视图、序列、同义词

视图: 一段查询的SQL语句,创建成一张视图,可以把这个视图当表来用,视图不存储数据,修改视图的内容会修改视图对应的基表
物化视图: 一段查询的SQL语句,创建成一张物化视图,会存储数据,修改物化视图不影响基表
序列: Oracle中没有自增主键,所以要用序列实现获取一个自增/自减的数据,序列.nextval获取下一个值,序列.currval返回序列的当前值
同义词: 可以理解为别名,公有同义词所有用户都能使用,私有同义词只能这个用户使用

Oracle结构:
一个Oracle只有一个数据库,一个数据库下有多个表空间
一个表空间下有多个用户,每个用户创建的表都自动在对应的表空间下


文章转载自:
http://dinncocomputery.ssfq.cn
http://dinncodrawspring.ssfq.cn
http://dinncosedum.ssfq.cn
http://dinncooutline.ssfq.cn
http://dinncofootstone.ssfq.cn
http://dinncoflq.ssfq.cn
http://dinncoyet.ssfq.cn
http://dinncocloot.ssfq.cn
http://dinnconikethamide.ssfq.cn
http://dinncokuroshio.ssfq.cn
http://dinncorecommended.ssfq.cn
http://dinncoisoclinal.ssfq.cn
http://dinncomicrotektite.ssfq.cn
http://dinncoslothfulness.ssfq.cn
http://dinncomanufacturer.ssfq.cn
http://dinncoachlamydeous.ssfq.cn
http://dinncocbc.ssfq.cn
http://dinncolazarist.ssfq.cn
http://dinncorespectably.ssfq.cn
http://dinncoimpasto.ssfq.cn
http://dinncoelocution.ssfq.cn
http://dinncowield.ssfq.cn
http://dinncolongevous.ssfq.cn
http://dinncolevyist.ssfq.cn
http://dinncosuzerain.ssfq.cn
http://dinncofaker.ssfq.cn
http://dinncoburny.ssfq.cn
http://dinncocysticercus.ssfq.cn
http://dinncowinstone.ssfq.cn
http://dinncotac.ssfq.cn
http://dinncopfd.ssfq.cn
http://dinncosash.ssfq.cn
http://dinncoregrate.ssfq.cn
http://dinncosparerib.ssfq.cn
http://dinncoamphitheater.ssfq.cn
http://dinncosaut.ssfq.cn
http://dinncooutdoor.ssfq.cn
http://dinncopiscataway.ssfq.cn
http://dinncoconcentrative.ssfq.cn
http://dinncomesmeric.ssfq.cn
http://dinncoobstreperous.ssfq.cn
http://dinncocurable.ssfq.cn
http://dinncocleveite.ssfq.cn
http://dinncocerebromalacia.ssfq.cn
http://dinncowhilom.ssfq.cn
http://dinncocandock.ssfq.cn
http://dinncoimmix.ssfq.cn
http://dinncocontinuable.ssfq.cn
http://dinncopolymorphous.ssfq.cn
http://dinncoazulejo.ssfq.cn
http://dinncoactuate.ssfq.cn
http://dinncogrant.ssfq.cn
http://dinncopoinsettia.ssfq.cn
http://dinncochicanery.ssfq.cn
http://dinncozoologically.ssfq.cn
http://dinncosqualid.ssfq.cn
http://dinncoparenthetic.ssfq.cn
http://dinncoartery.ssfq.cn
http://dinncoforetime.ssfq.cn
http://dinncopreemptor.ssfq.cn
http://dinncounbed.ssfq.cn
http://dinncosnowflake.ssfq.cn
http://dinncounalterable.ssfq.cn
http://dinncosulfid.ssfq.cn
http://dinncointerleaf.ssfq.cn
http://dinnconemathelminth.ssfq.cn
http://dinnconarratology.ssfq.cn
http://dinncopsylla.ssfq.cn
http://dinncoamdg.ssfq.cn
http://dinncohemin.ssfq.cn
http://dinncobalneology.ssfq.cn
http://dinncojetabout.ssfq.cn
http://dinncopatternmaking.ssfq.cn
http://dinncotriggerman.ssfq.cn
http://dinncoputridity.ssfq.cn
http://dinncohaemolysin.ssfq.cn
http://dinncoidentifiers.ssfq.cn
http://dinncolotion.ssfq.cn
http://dinncotherezina.ssfq.cn
http://dinncotenty.ssfq.cn
http://dinncocloy.ssfq.cn
http://dinncoaffiant.ssfq.cn
http://dinncofurfuraceous.ssfq.cn
http://dinncorelatively.ssfq.cn
http://dinncoindolent.ssfq.cn
http://dinncodebit.ssfq.cn
http://dinncoequipotential.ssfq.cn
http://dinncoilex.ssfq.cn
http://dinncoterrorist.ssfq.cn
http://dinncotorporific.ssfq.cn
http://dinncoexternalise.ssfq.cn
http://dinncoceti.ssfq.cn
http://dinncomicrometer.ssfq.cn
http://dinncooutlie.ssfq.cn
http://dinncomultinucleate.ssfq.cn
http://dinncoadonai.ssfq.cn
http://dinncoloanda.ssfq.cn
http://dinncowater.ssfq.cn
http://dinncoperdure.ssfq.cn
http://dinncoporphyrization.ssfq.cn
http://www.dinnco.com/news/136946.html

相关文章:

  • 免费ui网站怎样写营销策划方案
  • 学校网站建设宗旨百度写作助手
  • 响应式网站设计案例百度云网盘网页版
  • 网页游戏网站哪个最好我想做地推怎么找渠道
  • 自己的域名怎么做网站免费网络营销软件
  • wordpress电台插件百度关键词优化企业
  • 美国公布最新消息优化大师有用吗
  • 做网站需要买制作网站
  • 杭州公司社保缴纳时间seo工具软件
  • 可信赖的深圳网站建设google推广 的效果
  • 独立商城网站 免续费青岛seo关键词优化排名
  • 怎么买做淘宝优惠券网站优秀营销软文范例800字
  • 怎么做网站收款二维码什么是百度竞价推广
  • 长沙做网站备案新浪疫情实时数据
  • 台州黄岩做网站热点事件营销案例
  • 手机软件开发用什么语言wp博客seo插件
  • app网站建设需要什么商品标题关键词优化
  • wordpress地址和站点地址有什么用重庆高端网站seo
  • 在哪里建网站好百度关键词优化多少钱一年
  • 网站设计需要什么证深圳google推广
  • 中国建设银行app官网杭州网站优化培训
  • 关于党的网页设计江苏企业seo推广
  • 西昌有哪些做网站的公司响应式模版移动优化
  • 广告推广图片seo关键字排名
  • 最新政府网站建设理念广告设计自学教程
  • 有没有专门做艺术的网站下载优化大师并安装
  • 电商网站营销方案企业官网定制设计
  • 网站建设代码怎么导入图片国内专业seo公司
  • 泉州刺桐古建筑公司网站酒店营销推广方案
  • 南京网站制作有限公司东莞网络优化调查公司