Oracle sql 函数
SQL中的单记录函数1.ASCII返回与指定的字符对应的十进制数;SQL> select ascii('A') A,ascii('a') a,ascii('0') zero,ascii(' ') space from dual; A A ZERO SPACE--------- --------- --------- --------- 65 97 48 322.CHR给出整数,返回对应的字符;SQL> select chr(54740) zhao,chr(65) chr65 from dual;ZH C-- -赵 A3.CONCAT连接两个字符串;SQL> select concat('010-','88888888')||'转23' 高乾竞电话 from dual;高乾竞电话----------------010-88888888转234.INITCAP返回
oracle sql 注意点
1.select 中的字符串不需注意大小写但where后面的字符串需注意列名无需注意,值需要注意。2.select pname AS pn 别名不加引号默认显示列为大写,加引号为引号内的字体,并且pn为双引号不是单引号。3.where lower(pname)='she'最好使用这种格式,若中文无需考虑。4.select pname,sal*12+500,location列名可以加表达式5.where pname like 'pkdata_%'escape ''使用转义字符将_表示为字符串的一部分,而不是占位符。6.order by默认asc从小到大。7.order 可以使用列号。select pname,pno,location .......order by 1 ASC8.order 后可以不跟已选
查找重复值
比如现在有一人员表 (表名:peosons)若想将姓名、身份证号、住址这三个字段完全相同的记录查询出来 select p1.* from persons p1,persons p2 where p1.id<>p2.id and p1.cardid = p2.cardid and p1.pname = p2.pname and p1.address = p2.address可以实现上述效果.几个删除重复记录的SQL语句1.用rowid方法2.用group by方法3.用distinct方法1。用rowid方法据据oracle带的rowid属性,进行判断,是否存在重复,语句如下:查数据: select * from table1 a where rowid !=(select max(rowid) from table1 b where a.name1=b.name1 and
ORACLE 函数之nvl
nvl函数函数声明:nvl(col,val)说明:当col为空时取val作为返回值,当col不为空时取col值。如果val类型与col类型不同,首先将val类型转化为col类型 &...
几个有用的SQL语句
select * into b from a where 1<>1 (只复制结构)复制表insert into b select * from a &nb...