--2.查看表结构
desc wx_monitor_excption; --3.从表中查询数据
select * from wx_monitor_excption; --7.双引号保持原来的格式
select id "id1" from wx_monitor_excption; --6.查询当前系统的日期
select sysdate from dual; --8.查询数字时,把为空值的换为0,oracle中空值运算结果都为null
select id,remark from wx_monitor_excption where remark is null;
select id,plate_number,nvl(remark,'null') from wx_monitor_excption; --9.字符串连接(把两个字段查询出来的数据作为一条字符串输出)两个单引号代替一个
select id||openid from wx_monitor_excption;
select id||'nimei' from wx_monitor_excption; --10.去掉重复的值(也会去掉多个字段组合重复的值)
select distinct plate_number from wx_monitor_excption; --12.条件 between and (包含800和1500) 'or' and 'and'
select * from wx_monitor_excption where (create_time between '26-12月-14' and '30-12月-14') or exception_category='堵车上报';
select * from wx_monitor_excption where create_time>='26-12月-14' and create_time<='30-12月-14'; --15. 模糊查询 %零个或多个,下横线_代表一个
select * from wx_monitor_excption where position like '%上海%'; --17.排序 order by 默认升序asc
select * from wx_monitor_excption order by create_time asc; --18.函数 转化为小写lower()
select lower(openid) from wx_monitor_excption; --19.函数 截子串substr(ename,2,3) 从字符串ename中第2个开始截,一个截3个字符
select substr(openid,6,4) from wx_monitor_excption; --20.函数 把数字转化为相应的字母,相反 ascii('A')
select chr(77) from dual; --21.函数 四舍五入
select round(23.77) from dual;
select round(23.456,2) from dual;
select round(23.456,-1) from dual; --22.函数 把数字或字母或日期转化为特定的格式 to_char(sal,'$99,999.9999'), $换成L,显示¥
select to_char(create_time,'yyyy-MM-dd hh24:mm:ss') from wx_monitor_excption;
select * from wx_monitor_picstatus;
select to_char(len,'$99,999.99') from wx_monitor_picstatus;
select to_char(len,'$00,000.00') from wx_monitor_picstatus; --23.函数 把特定的字符转化为日期 to_date('', '')
select to_char(sysdate,'YYYY-MM-DD HH24:MI:SS') from dual; --24.函数 把特定的字符转化为数字 to_number('$1,250.00', '$9,999.99')
select * from wx_monitor_picstatus where len>to_number('',''); --27.组函数 求出总共多少条数据 count(*),count(ename), 凡是不是空值的字段一共有几个
select count(*) from wx_monitor_picstatus; --28.函数 分组查询 group by
select openid,count(openid) from wx_monitor_excption group by openid; --45.创建视图 create view v$name as 重复使用的语句. 视图就是一个子查询,就是一张表
create view nimei as select * from wx_monitor_excption where plate_number='沪A12312'; --46.插入语句
insert into wx_monitor_excption(id,openid,carline,plate_number,phone_number) values('','','','','');
select * from wx_monitor_excption where id=''; --47.备份表
create table tab1 as select * from wx_monitor_excption;
--删除表中的数据
delete from tab1;
select * from tabl;
--完全删除表
drop table TAB1; --48.伪字段 rownum 默认从第一行往后排列序号1,2,3等,必须< = 号;
select * from wx_monitor_excption where rownum<10;
rollback;
commit; --54.约束 自定义名字 非空约束
create table TAB1(id number(5),name varchar(50) not null);
select * from tab1;
desc tab1;
insert into tab1 values(123,'wooooo',''); --58.修改现有表的表结构
alter table tab1 drop(create_time);
alter table tab1 add(create_time varchar2(50));
alter table tab1 modify(create_time varchar(10)); --64.索引 index
create index syname on wx_monitor_excption(plate_number,openid);
desc wx_monitor_excption; --65.删除索引
drop index syname; --66.序列 oracle独特的 自动递增
create sequence sename;
drop sequence sename;
select sename.nextval from dual;

Oracle常用SQL语句的更多相关文章

  1. oracle常用SQL语句(汇总版)

    Oracle数据库常用sql语句 ORACLE 常用的SQL语法和数据对象一.数据控制语句 (DML) 部分 1.INSERT (往数据表里插入记录的语句) INSERT INTO 表名(字段名1, ...

  2. oracle 常用sql语句

    oracle 常用sql语句 1.查看表空间的名称及大小 select t.tablespace_name, round(sum(bytes/(1024*1024)),0) ts_sizefrom d ...

  3. Oracle常用SQL语句大全

    常用Oracle数据库SQL语句汇总. 1.常用操作 --清空回收站purge recyclebin;--查询回收站select * from recyclebin--查询Oracle版本信息sele ...

  4. Oracle 常用Sql 语句

    Oracle数据库常常被用作项目开发的数据库之一:有时隔段时间没使用就会忘记一些常用的sql语法,所以我们有必要记录下常用的sql 语句,当我们需要时可以快速找到并运用. 1 创建表空间.创建用户及授 ...

  5. Oracle常用sql语句(一)

    # Sql的分类 # DDL (Data Definition Language):数据定义语言,用来定义数据库对象:库.表.列等: CREATE. ALTER.DROP DML(Data Manip ...

  6. Oracle常用sql语句。

    最近工作中遇到了一些与oracle相关的问题,稍微整理一些工作中用到的SQL语句 时间相关 --查询距当前时间十分钟内的数据 select sysdate -interval '10' minute ...

  7. Oracle常用sql语句(二)之组函数、多表查询

    DML(数据操纵语言) INSERT .UPDATE. DELETE 插入操作:INSERT: 语法: INSERT INTO 表名(列名1,列名2 ...)VALUES(列值1,列值2...); 注 ...

  8. oracle常用sql语句和函数

    --查询表的字段数 select count(*) from user_tab_columns where table_name = '表名'; --查询数据库用户密码的profile(一般为defa ...

  9. Oracle常用sql语句(三)之子查询

    子查询 子查询要解决的问题,不能一步求解 分为: 单行子查询 多行子查询 语法: SELECT select_list FROM table WHERE expr operator (SELECT s ...

随机推荐

  1. easyui 中重复加载两次url

    之前一直在使用easyui中,忽视了官网上的小细节,类似于datagrid.combobox 等组件在使用的时候,它的数据加载方式分为两种: 官网中: ①在html中,比如: <table id ...

  2. BZOJ2621 [Usaco2012 Mar]Cows in a Skyscraper

    首先比较容易想到是状态压缩DP 令$f[S]$表示选取了集合$S$以后,已经送了最少次数$cnt$且当前电梯剩下的体积$rest$最大(即$f[S]$是一个二元组$(cnt, rest)$) 于是$f ...

  3. 使用NuGet时的一个乌龙

    问题描述 最近自己做的一个项目,计划开始使用NuGet来管理dll,但是遇到一个奇怪,但是结果证明是个乌龙的问题. 新建一个WebApi项目,使用NuGet管理第三方dll,其中有引用Newtonso ...

  4. sql server中备份数据的几种方式

    当我们在写sql脚本要对数据表中的数据进行修改的时候,为了防止破坏数据,通常在开发前都会对数据表的数据进行备份,当我们sql脚本开发并测试完成后,再把数据恢复回来. 目前备份数据,我常用的方法有以下几 ...

  5. VS2010 winform程序发布步骤

    1.右键单击解决方案,点击“添加”---“新建项目”,如下图: 2.选择“其他项目类型”--“安装和部署”--“Visual Studio Installer”---"安装项目", ...

  6. ubuntu14.10服务器版安装xampp,配置域名端口访问

    1.从xampp下载下了xampp-linux-1.7.3a.tar这个包,然后ftp到我的linux虚拟机中, 2.复制到opt下,(可以直接解压的)到opt下面,tar xvfz xampp-li ...

  7. centos ssh配置使用

    配置 数据阶梯 CentOS SSH配置 默认CentOS已经安装了OpenSSH,即使你是最小化安装也是如此.所以这里就不介绍OpenSSH的安装了. SSH配置: 1.修改vi /etc/ssh/ ...

  8. 用PHP做服务器接口客户端用http协议POST访问安全性一般怎么做

    我的问题是,如果不做安全相关处理的话,一些可能改变数据库的操作可能会遭遇垃圾数据提交什么的,毕竟要找到这些信息只要找个http包就可以了 系统无用户登录 新手问题(从来没做过服务端开发),如果可以,给 ...

  9. if语句使用

    package yuan; public class Yuan { public static void main(String[] args) { int a = 1; int b = 8; int ...

  10. hdu 4631 Sad Love Story

    http://acm.hdu.edu.cn/showproblem.php?pid=4631 没想到这道题需要用“平均时间复杂度” 计算   一直没有想到解法  因为不符考虑了最坏情况的理念 方法一: ...