09 2013 档案
摘要:1.if 逻辑结构 if/then 结构是最简单的条件测试,如果条件为真,则执行程序的一行或者多行,如果条件为假,则什么都不执行,示例: if 1>2 then null; end if ; if not 12 then null; else null; end if ; if /then /elsif ,在这中结构,在条件为false 是可以对另一个条件测试,因此,不用嵌套if语句也可以对多个条件进行测试 示例; if 1>2 then null; elsif 1>3 null; else null; end if ;备注;每一个if语句块必须至少有一行程序代码,如果不希望
阅读全文
摘要:1.视图 视图是基于一个或者多个表数据库对象,视图允许用户创建一个无数据的”伪表“,视图只是一个获取特定列好行的sql查询组成,通过视图检索数据就像从表中检索数据 一样。视图可以提供一个附加的安全层,是一个或者多个表中只有某些行和列对最终用户可用。可以对组织的所有用户隐藏基表 只允许他们浏览某些数据。示例: select view utach_sales as select c.cust_id ID, substr(cust_last_name,1,20) Name, substr(cust_city,1,20) City,substr(cust_state_province,1,5) Sta
阅读全文
摘要:1.内连接 内连接通常称为连接,内连接发生在从两个表中选取记录且第一个表中某一列的值能在第二个表的相同列中找到 ,实际中,两个或者多个表连接是基于共同的字段。 一般这些共同字段都是主键 示例:select prod_id ,quantity_sold,cust_city,cust_state_province from sales ,customers where sales.cust_id = custmoers.cust_id and prod_id = 117;如果连接的表比较多,就很有可能混乱,所以有必要为你表的指定别名 来实现内联的查询 示例: select s.cust_id ,s
阅读全文
摘要:1.字符串函数 lower(char)将整个字符串转换为小写 示例:select lower('DALiA') from dual; =>dalia replace(char ,str1,str2) 将char中出现的每个str1替换成str2 示例:select replace('Scott','S','Boy') from dual;=>boycott substr(char ,m ,n) 从char中第m 个字符开始去n个字符 示例: select substr('ABCDEF',4,2) fro
阅读全文
摘要:1.update语句 update table set [column,column......] where column ='' 示例: update customers set cust_credit_limit = 20000 where cust_id = 2789;2.delete 语句 delete from table where 条件 示例; delete from customers where cust_state_province = 'QT';备注;truncate customers 也可以删除该表的所有记录,但是它在出错不允许回滚的
阅读全文
摘要:1.数据库操纵语言(Data manipulation language )DML DML 是以任何select ,insert ,update 或 delete开头的sql 语句。 1.1 insert 示例:insert into customer value(1,'name') 或者insert into customer (id,name) values(2,'name2') 1.2seelect示例: select * from customer ; 备注: * 表示提取所用的列的数据 1.2.1 添加where 条件 示例:select prodId
阅读全文