导航

oracle SQL笔记

Posted on 2014-01-02 15:25  酷鱼影子  阅读(124)  评论(0编辑  收藏  举报

oracle三元运算

case when 1<2 then 'yes' else 'no' end

相当于你的三元运算符 1<2? 'yes':'no'

?

SELECT t_sys_dlxxb.id,
t_sys_dlxxb.dldm,
t_sys_dlxxb.lkh,
t_sys_dlxxb.lm,
t_sys_dlxxb.xzqm,
t_sys_dlxxb.xzqh,
t_sys_dlxxb.lkldm || (case when t_sys_dlxxb.zddl is not null then '('||t_sys_dlxxb.zddl||')' else t_sys_dlxxb.zddl end),
t_sys_dlxxb.pysx,
t_sys_dlxxb.xtsx,

FROM t_sys_dlxxb


to_char(dates.END_DATE, 'yyyy-mm-dd')


如何从结构相同的两张表中按条件查询数据

select  * from (select * from table_a union all select * from table_b) where 条件

如何在Oracle中复制表结构和表数据

1. 复制表结构及其数据:

create table table_name_new as select * from table_name_old

2. 只复制表结构:

create table table_name_new as select * from table_name_old where 1=2;

3. 只复制表数据:

如果两个表结构一样:

insert into table_name_new select * from table_name_old

如果两个表结构不一样:

insert into table_name_new(column1,column2...) select column1,column2... from table_name_old

pasting