#截取数字
SELECT TRUNC(15.79,1) "Truncate" FROM DUAL; //15.79取一位小数,得15.7
SELECT ROUND(15.75, 1) rounded , ROUND(15.71,1) truncated from dual //四舍五入
SELECT FLOOR(ROUND(15.79, 0)), FLOOR(ROUND(15.79, 0,1) )
#查看长度
SELECT LENGTH('SQLMAG') "Length in characters" FROM DUAL;
SQLMAG的长度为6
#tns存放位置(数据库配置文件)
\oracle\product\10.2.0\db_1\NETWORK\ADMIN\tnsnames.ora
##ftp数据传输(ETL望对方服务器上推送数据)
cd /home/tmn/apps/etl_data/OTT_DATA/$day$/
lftp -u username,password ftp://10.238.68.11<
mkdir $day$
cd $day$
put XQGL_INDOOR_$day$.csv
bye
EOF
##查看端口被哪个进程占用
netstat -lnp|grep 端口号
##Linux按日期删除文件夹
rm -rf *$CustFunc:getTime(yyyyMMdd,-D3,DAY)$*
##按时间过滤文件
_$TIME(yyyyMMdd,-D1)$.csv
##文件入库,在输入记录中跳过各种不同的列,在列名后空格加上'FILLER'
##导入数据忽略表头
LOAD DATA
CHARACTERSET ZHS16GBK
INFILE '$FILE_PATH$' "str X'0D0A'"
APPEND
INTO TABLE cm.o_ALARM
when (1) <>'sheetid' //sheetid为表头第一个字段名称
FIELDS TERMINATED BY '|'
TRAILING NULLCOLS
()
##查询当前数据库名
select name from v$database;
##查询数据库实例名
select instance_name from v$instance;
##清理服务器启动日志文件
echo>catalina.out
##匿名自我调用函数
(function () {
var x = "Hello!!"; // 我将调用自己
})();
##xml文档
所包含的内容将表示为纯文本
##decode函数
1、改字段名称,将原有地市名称中“市”字去掉
DECODE(CITY_NAME,'平凉市','平凉','张掖市','张掖','白银市','白银','陇南市','陇南','金昌市','金昌','天水市','天水','临夏回族自治州','临夏','酒泉市','酒泉','武威市','武威','嘉峪关市','嘉峪关','庆阳市','庆阳','定西市','定西','兰州市','兰州','甘南藏族自治州','甘南','UNKNOW') AS CITY_NAME,
2、某一number类型字段显示时,零点几中不显示零的问题
decode(substr(ESTIAME_TOTAL_AREA,1,1),'.','0'||ESTIAME_TOTAL_AREA,ESTIAME_TOTAL_AREA)
##接口
http://127.0.0.1:7200/irms/services/TbnsGsPersonnelMreportProcessWebService?wsdl
#查找字段所在的表
select * from all_col_comments where column_name = 'CGI'
#date类型转换为number类型
to_number(to_char(DAY_KEY,'yyyymmdd')) //day_key为date类型
#序列号查询
select * from dba_sequences where sequence_name like '%SEQ_T_COMPLAINT_EOMS'
#查询被锁的表
select object_name, machine, s.sid, s.serial#
from v$locked_object l, dba_objects o, v$session s
where l.object_id = o.object_id
and l.session_id = s.sid
#解锁表、注意修改sid和seria#的值
alter system kill session 'sid,serial#';
select spid, osuser, s.program
from v$session s,v$process p
where s.paddr=p.addr and s.sid=1707
#dblink建立
--查询所有已存在dblink
select * from all_db_links;
-- Create database link
create public database link ZIGUAN
connect to WNMS
using '10.238.50.200:1521/SDH';
或者
create public database link ZIGUAN
connect to WNMS
identified by "WNMS-200"
using '(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=10.238.50.200)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=SDH)))';
--delete database link
drop public database link xxx;
##各地市小区合计
select decode (city_name,null,'省合计',A.CITY_NAME) CITY_NAME,
count(distinct a.unique_key) "小区数" ,
count(distinct a.enbfunction_uk) "基站数"
from cm.f_l_c_eutrancelltdd a
group by rollup(city_name) ;
#rollup()函数
Rollup(a,b,c): (a,b,c),(a,b),(a),(全表)
##数据库创建角色
*创建用户角色
create role 角色名
*oracle对用户赋权限
grant connect,resource to 用户名
*撤销权限
revoke connect,resonurce from 用户名
##解锁被锁用户(ORA-28000: the account is locked)
alter user 用户名 account unlock;
##将.class文件打成jar包
在.class文件的com文件夹目录下打开cmd界面
输入 jar -cvf 包名 文件名
具体命令可在cmd下输入jar回车看具体命令
##ROW_NUMBER()
ROW_NUMBER() OVER(ORDER BY BEGIN_TIME ASC) TOP
##通过一个字段删除重复数据保留一行
delete from cellinfo
where celleci in (select celleci
from cellinfo
group by celleci
having count(celleci) > 1)
and id not in (select min(id)
from cellinfo
group by celleci
having count(*) > 1)