oracle常用函数:
oracle 串函数
|| 连接符
SQL> select id||' '||xingming from t11;
TO_CHAR 是把日期或数字转换为字符串
SQL> select to_char(123,'9999.00') from dual;
SQL> select to_char(123,'$99,999.99') from dual;
查看时间
SQL> select sysdate from dual;
SQL> select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
SQL> select gongzi from t9 where name='zs' and substr(to_char (d,'yyyy-mm-dd'),1,4)='2012';
substr 截取函数
SQL> select substr('abcdef',2,3) from dual;
(截取从第二个字符开始的3个字符)
SQL> select substr('abcdef',-5) from dual;
(截取后5位)
聚集函数
avg(平均值)
SQL> select avg(gongzi) from t9;
sum(求和)
SQL> select sum(gongzi) from t9;
min(最小值)
SQL> select min(gongzi) from t9;
max(最大值)
SQL> select max(gongzi) from t9;
count(行计数)
SQL> select count(*) from t9;
vm_concat合并列
SQL> create table ww (id int,name varchar2(10),gz int);
Table created.
SQL> insert into ww values (1,'zs',10000);
SQL> select id,wm_concat(name) from ww group by id;
显示每部门人名和工资
SQL> select id,wm_concat(name||'('||gz||')') from ww group by id;
sqrt 求平方根
SQL> select sqrt(64) from dual;
Round 函数 (四舍五入)
SQL> select round(123.123) from dual;
SQL> select round(123.8) from dual;
trunc 截掉小数点后值
SQL> select trunc(123.8) from dual;
sign取数字n的符号,大于0返回1,小于0返回-1,等于0返回0
SQL> select sign(100),sign(-100),sign(0) from dual;
删除重复行
SQL> select distinct(xingming) from t11;
abs ceil 返回绝对值
SQL> select abs(-5) from dual; (返回值为5)
SQL> select abs(5.5) from dual;(返回值为5.5)
SQL> select ceil(5.4) from dual;(返回值为6)
如果pfile和spfile全部丢失,如何启动oracle?
[oracle@oracle ~]$ cd /oracle/app/admin/TEST/bdump/
[oracle@oracle bdump]$ ls
alert_TEST.log test_lgwr_22103.trc test_lgwr_8829.trc
test_lgwr_18215.trc test_lgwr_4598.trc test_lgwr_8928.trc
[oracle@oracle bdump]$ tail -f -n 200 alert_TEST.log
processes = 150
__shared_pool_size = 79691776
__large_pool_size = 4194304
__java_pool_size = 4194304
__streams_pool_size = 0
sga_target = 285212672
control_files = /oracle/app/oradata/TEST/control01.ctl, /oracle/app/oradata/TEST/control02.ctl, /oracle/app/oradata/TEST/control03.ctl
db_block_size = 8192
__db_cache_size = 192937984
compatible = 10.2.0.1.0
db_file_multiblock_read_count= 16
db_recovery_file_dest = /oracle/app/flash_recovery_area
db_recovery_file_dest_size= 2147483648
undo_management = AUTO
undo_tablespace = UNDOTBS1
remote_login_passwordfile= EXCLUSIVE
db_domain =
dispatchers = (PROTOCOL=TCP) (SERVICE=TESTXDB)
job_queue_processes = 10
background_dump_dest = /oracle/app/admin/TEST/bdump
user_dump_dest = /oracle/app/admin/TEST/udump
core_dump_dest = /oracle/app/admin/TEST/cdump
audit_file_dest = /oracle/app/admin/TEST/adump
db_name = TEST
open_cursors = 300
pga_aggregate_target = 94371840
将其粘到initTEST.ora
再重新启动,如果发现有问题,就将initTEST.ora中的db_domain =
dispatchers = (PROTOCOL=TCP) (SERVICE=TESTXDB) 两行删除再重启即可。