select to_char(current_timestamp,'yyyy-mm-dd hh24:mi:ss.ff3'),to_char(sysdate,'yyyy-mm-dd hh24:mi:ss'),to_date('2010-01-10 00:00:00','yyyy-mm-dd hh24:mi:ss')  from dual;/*类型转换*/



select to_char(-485,'999') ,to_char(1485,'9,999'),to_char(1485.8,'99999.99') ,to_char(1485.8898,'99999.99')from dual;/*类型转换*/

select to_number('39202.88000','999999.99999') from dual;/*类型转换*/

select nvl('','null') from dual;/*空值转换*/

select decode(1,1,'man',2,'woman','unknow') from  dual;/*条件翻译*/

select substr(message,length(message)-1,2) from tb_liuyi;/*右截取*/

select round(3.1459,2),trunc(3.1415926,3),floor(3.943883),ceil(3.94),abs(-999.9),0-9999.8 from dual;

select count(*) as rn , sendtime from tb_liuyi having count(*)>1 group  by sendtime ;/*统计查询*/



select sid from tb_liuyi  where rownum<=5; /*取前5条*/

select * from (select rownum as rn ,A.* from (select * from tb_liuyi) A where rownum <10) where rn>5;/*分页查询5-10*/

select * from ALL_TABLES where table_name=upper('tb_liuyi');/*表空间*/

select * from ALL_TAB_COLUMNS where table_name=upper('tb_liuyi');/*表结构*/



select * from ALL_CONSTRAINTS where table_name=upper('tb_liuyi');/*表约束*/

select * from ALL_CONS_COLUMNS where table_name=upper('tb_liuyi');/*行约束*/



select   *   from   user_col_comments where table_name=upper('tb_liuyi');/行注释/

select   *   from   user_tab_comments where table_name=upper('tb_liuyi');/表注释/

/*建表*/

drop sequence SEQ_MY_TABLE_ID;

drop table MY_TABLE cascade constraints;

drop table MY_TABLE;

CREATE TABLE MY_TABLE

(

   sid NUMBER(16) NOT NULL PRIMARY KEY,

   message varchar2(255),

   sendtime date default sysdate ,

   fee NUMBER(12.2),

   mrk varchar2(1) default 'N' NOT NULL,

   overtime timestamp default current timestamp

);

 comment on column MY_TABLE.sid is '消息序号';

 /*建立索引*/

 create unique index MY_TABLE_IDX1 on MY_TABLE(

 sid,

 sendtime

 );

--create sequence

create sequence SEQ_MY_TABLE_ID

minvalue 1

maxvalue 999999999999999999999999999

start with 1

increment by 1

cache 20;

/*触发器*/

Create Or Replace Trigger Trig_liuyi

  After Insert Or Delete Or Update On tb_liuyi  For Each Row

Begin

  If Inserting Then

    Insert Into tb_liuyi_trig Values ('insert', Sysdate);

  Elsif Updating Then

    Insert Into tb_liuyi_trig Values ('update', Sysdate);

  Elsif Deleting Then

    Insert Into tb_liuyi_trig Values ('delete', Sysdate);

  End If;

End;

大规模导入数据使用sqlldr(详情见网络),

另外,oracle提供块查询的接口,具体见网络。

收藏于 2012-07-20
来自于百度空间

常见sql for oracle的更多相关文章

  1. Access、SQLServer、Oracle常见SQL语句应用区别

    Access.SQLServer.Oracle常见SQL语句应用区别 关劲松 PMP 如果要兼容Access.SQL Server.Oracle三个数据库版本:我们在编写SQL语句的过程中,尽量使用一 ...

  2. SQL优化(Oracle)

    (转)SQL优化原则 一.问题的提出 在应用系统开发初期.因为开发数据库数据比較少.对于查询SQL语句,复杂视图的的编写等体会不出SQL语句各种写法的性能优劣,可是假设将应用系统提交实际应用后,随着数 ...

  3. sql点滴41—mysql常见sql语法

    原文:sql点滴41-mysql常见sql语法 ALTER TABLE:添加,修改,删除表的列,约束等表的定义. 查看列:desc 表名; 修改表名:alter table t_book rename ...

  4. SQLServer 常见SQL笔试题之语句操作题详解

    SqlServer 常见SQL笔试题之语句操作题详解 by:授客 QQ:1033553122 测试数据库 CREATE DATABASE handWriting ON PRIMARY ( name = ...

  5. MySQL · 性能优化 · MySQL常见SQL错误用法(转自-阿里云云栖社区)

    作者:阿里云云栖社区链接:https://zhuanlan.zhihu.com/p/26043916来源:知乎著作权归作者所有,转载请联系作者获得授权. 前言 MySQL在2016年仍然保持强劲的数据 ...

  6. 常见SQL注入点判断

    sql注入手工检测 SQL注入手工检测 1基本检测 数字型 字符型 搜索型 POST注入 布尔盲注 报错注入 堆叠注入 判断是什么数据库 2绕过技巧 大小写 替换关键字 使用编码 注释和符号 等价函数 ...

  7. 【SQL】Oracle分页查询的三种方法

    [SQL]Oracle分页查询的三种方法 采用伪列 rownum 查询前10条记录 ? 1 2 3 4 5 6 7 8 9 10 11 [sql] select * from t_user t whe ...

  8. 历尽磨难之PL/SQL链接Oracle数据库

    说起来都是泪啊,上司布置的任务需要远程连接Oracle数据库,说实话这又是我人生中的第一次.我听到以后觉得不是什么大问题,然而我错了..错的很厉害! 我搞了一天一夜才弄好,这里面原因有很多,大体来讲还 ...

  9. General Ledger Useful SQL Scripts – Oracle Applications 11i

    General Ledger Useful SQL Scripts – Oracle Applications 11i Contents GL Set of Books Configuration O ...

随机推荐

  1. UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 120: illegal multibyte sequence

    UnicodeDecodeError: 'gbk' codec can't decode byte 0xae in position 120: illegal multibyte sequence f ...

  2. HTML5 Canvas ( 图形的透明度和遮盖 ) globalAlpha, globalCompositeOperation

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  3. leetcode29

    class Solution { public int divide(int dividend, int divisor) { if (dividend == Integer.MIN_VALUE &a ...

  4. Vue2.0中v-for迭代语法变化(key、index)

    语法发生了变化:http://blog.csdn.net/sinat_35512245/article/details/53966788 新数组语法 value in arr (value, inde ...

  5. eclipse插件常用网址链接

    目录 jar下载地址 java maven svn erMaster linux镜像ISO:       http://www.linuxfly.org/post/659/ virtual下载:    ...

  6. UI5-文档-4.38-Accessibility

    作为本教程的最后一步,我们将改进应用程序的可访问性. 为此,我们将添加ARIA属性.屏幕阅读器使用ARIA属性识别应用程序结构并正确解释UI元素.通过这种方式,我们可以让我们的应用程序对那些使用电脑有 ...

  7. 脚本中 %~dp0

    cmd窗口中 for /? 查询参数含义 %~dp0, 将参数转换为磁盘路径+名字 例: 脚本中一行 %~dp0abc.exe (abc.exe位置c:\test\abc.exe) 展开后则为 c:\ ...

  8. MVC控制器详解

    原文地址:http://www.cnblogs.com/SeeYouBug/p/6441934.html#3628606 目录 一.理解控制器 1.1.什么是控制器 1.2.控制器的作用 1.3.创建 ...

  9. 了解innodb_support_xa(分布式事务)

    innodb_support_xa可以开关InnoDB的xa两段式事务提交.默认情况下,innodb_support_xa=true,支持xa两段式事务提交.此时MySQL首先要求innodb pre ...

  10. hibernate中1对1的注解配置

    hibernate中1对1的注解配置分为:外键关联映射和主键关联映射 1.外键配置 //一方@Entity@Table(name="test_classinfo")public c ...