select to_char(
sysdate,
'yyyy-mm-dd') 格式日期
from dual;
select to_char(
sysdate,
'yyyy年mm月dd天') 格式日期
from dual;
select to_char(
12.34567,
'9999.99') 格式化数字
from dual; 12.35
select to_char(
12.34567.
'L9999.99') 格式化数字
from dual; ¥12.35
select
to_date(
'2011-4-8',
'yyyy-mm-dd') -
to_date(
'2011-4-10',
'yyyy-mm-dd') 日期差距
from dual;
select to_numner(
'123')+
2 求和
from dual;
select
'123'+
2 求和
from dual;
nvl(expr1,expr2): ===> expr1!=null ? expr1:expr2;
NVL2(expr1,expr2,expr3):===> expr1!=null ? expr2:expr3;
update employees
set salary=salary+
decode(deparment_id,
20,
100,
30,
80,
40,
120,
20);
select
sysdate 当前系统的时间
from dual;
select add_months(
sysdate,
1) 新的日期
Form dual;
select
sysdate
from dual;
select months_between(
'6-7月-11',
sysdate) 相差的月份
from dual;
select
floor(months_between(
'6-7月-11',
sysdate)) 相差的月份
from dual;
select
sysdate 当前日期,
last_day(
sysdate) 当月最后一天
form dual;
select
sysdate 当前日期,next_day(
sysdate,
'星期五') 下个星期五是
from dual
select
sysdate,
extract(
year
from
sysdate) 年,
extract(
month
from
sysdate) 月,
extract(
day
from
sysdate)日
from dual;
select
sysdate 当前日期,
sysdate+
1 日期加数字,
sysdate
-1 日期减数字,
sysdate-
to_date(
'2011-7-6',
'yyyy-mm-dd') 日期减日期,
floor(
sysdate-
to_date(
'2011-7-6',
'yyyy-mm-dd')) 日期差距取整
from dual;
select
abs(
-1)
form dual;
select
ceil (
1.33)
from dual;
select
floor(
1.33)
from dual;
select
power(
2,
3)
from dual;
select
mod(
10,
3)
from dual;
select
round(
12.126,
2)
from dual;
select trunc(
12.126,
2)
from dual;
三角函数 ....
select
lower(
'SccE')
from dual;
select
upper(
'scce')
from dual;
select
ltrim(
' adminscce')
from dual;
select
ltrim(
'adminscce',
'ad')
from dual;
select
rtrim(
'adminscce ')
from dual;
select
rtrim(
'adminscce',
'scce')
from dual;
select
replace(
'a*b*',
'*',
'/')
from dual;
select
replace(
'a*b*',
'*')
from dual;
select
replace(
'a*b*')
from dual;
select
replace()
from dual;
select
instr(
'abcdbc',
'bc')
from dual;
select
substr(
'scce',
2,
2)
from dual;
select
concat(
'scc',
'e')
from dual;
select
length(
'scce')
form dual;
grant
create syonoym
to scott;
grant
create
any
synonym
to scott;
create [
or
replace]
synonym syn_dept
for dept;
grant
create
public
synonym
to scott;
create [
or
replace]
public
synonym pubsyn_dept
for dept;
select *
from syn_dept;
conn scott/tiger@scce;
grant
select
on dept
to hr;
conn hr/tiger@scce;
select *
from scott.syn_dept;
conn hr/tiger@scce;
create
or
replace
synonym syn_scott_dept
for scott.dept;
conn scott/tiger@scce;
grant
select
on dept
to hr;
conn hr/tiger@scce;
select *
from syn_scott_dept;
conn hr/tiger@scce;
select *
from pubsyn_dept;
conn scott/tiger@scce;
revoke
select
on dept
from hr;
conn hr/tiger@scce;
select *
from pubsyn_dept;
drop
synonym syn_dept;
conn sys/admin@scce;
grant
drop
any
synonym
to scott;
conn scott/tiger@scce;
drop
synonym syn_scott_dept;
conn sys/admin@scce;
grant
drop
public
synonym
to scott;
conn scott/tiger@scce;
drop
public
synonym pubsyn_dept;