oracle10g- oracle数据语言 常用函数 日期格式
2010-09-30 09:45
411 查看
数据语言 ddl create alter drop定义dcl grant revoke控制dml select delete update insert操作
create table tt(c1 varchar2(10),c2 varchar(6));
alter table tt add cc number;alter table tt drop column c2;
grant select on tt to scott;revoke select on tt from scott;
insert into tt values('dfs','ss');update tt set c2='dd' where c1='dfs';
select substr('01234567',1,4) from dual;//0123不支持left right函数 select substr('01234567',1,4) from dual //相当于leftselect substr ('01234567',length('01234567')-4+1,4) from dual; --相当于right
**************select sysdate from dual;设置时间 格式alter session set nls_date_fromat='dd-mon-yyyy hh:mi:ss';select next_day(sysdate,'星期三') from dual;//星期几不能是数字 像3 或星期3 表示从今天开始下一个星期三是哪一天
select to_char(sysdate,'yyyy-mm-dd') from dual;select to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual;select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
select to_date('2010-3-2') from dual;select to_number('343') from dual;
select sum(decode(sex,'男',1,0)) 男生数,sum(decode(sex,'女',1,0)) 女生数 from tablename;
如果有的列有空值可以用其他数据来代替select id,nvl(name,'待输入') from t1;select id from t1 where name is null;//这里不能用=号select id from t1 where name is not null;
select * from t1 order by id asc;select * from t1 order by id desc;
select * from t1 exists (select * from t1);
select distinct name from t1;
select * from t1 exists (select * from t1 where t1.name is not null);oracle 中常用的系统函数1.字符 length,lengthb, ltrim. replace, rtrim, substr, trim.2.日期 sysdate current_date,next_day.3.转换 to_char ,to_date,to_number4.聚焦 sum,avg,max,min,count5.其他 user,decode,nvl
select lenght('司要民a') from dual;select ltrime(' ddd') from dual;select rtrime('ddd ') from dual;select trime(' ddd ') from dual; 常与varchar char 一块用
聚焦函数不能做为条件 写在where子句的后面
如 select pub from books where sum(price)>90 会报错应该这样写select pub from books group by pub heaving sum(price)>90;
select id ,name from t1 union 取并集select id,name from t2
select id ,name from t1interectselect id,name from t2//取交集
insert into t1(name) select name from t2;create tablet3 as (select id ,name from t3)
create table tt(c1 varchar2(10),c2 varchar(6));
alter table tt add cc number;alter table tt drop column c2;
grant select on tt to scott;revoke select on tt from scott;
insert into tt values('dfs','ss');update tt set c2='dd' where c1='dfs';
select substr('01234567',1,4) from dual;//0123不支持left right函数 select substr('01234567',1,4) from dual //相当于leftselect substr ('01234567',length('01234567')-4+1,4) from dual; --相当于right
**************select sysdate from dual;设置时间 格式alter session set nls_date_fromat='dd-mon-yyyy hh:mi:ss';select next_day(sysdate,'星期三') from dual;//星期几不能是数字 像3 或星期3 表示从今天开始下一个星期三是哪一天
select to_char(sysdate,'yyyy-mm-dd') from dual;select to_char(sysdate,'yyyy-mm-dd hh:mi:ss') from dual;select to_char(sysdate,'yyyy-mm-dd hh24:mi:ss') from dual;
select to_date('2010-3-2') from dual;select to_number('343') from dual;
select sum(decode(sex,'男',1,0)) 男生数,sum(decode(sex,'女',1,0)) 女生数 from tablename;
如果有的列有空值可以用其他数据来代替select id,nvl(name,'待输入') from t1;select id from t1 where name is null;//这里不能用=号select id from t1 where name is not null;
select * from t1 order by id asc;select * from t1 order by id desc;
select * from t1 exists (select * from t1);
select distinct name from t1;
select * from t1 exists (select * from t1 where t1.name is not null);oracle 中常用的系统函数1.字符 length,lengthb, ltrim. replace, rtrim, substr, trim.2.日期 sysdate current_date,next_day.3.转换 to_char ,to_date,to_number4.聚焦 sum,avg,max,min,count5.其他 user,decode,nvl
select lenght('司要民a') from dual;select ltrime(' ddd') from dual;select rtrime('ddd ') from dual;select trime(' ddd ') from dual; 常与varchar char 一块用
聚焦函数不能做为条件 写在where子句的后面
如 select pub from books where sum(price)>90 会报错应该这样写select pub from books group by pub heaving sum(price)>90;
select id ,name from t1 union 取并集select id,name from t2
select id ,name from t1interectselect id,name from t2//取交集
insert into t1(name) select name from t2;create tablet3 as (select id ,name from t3)
相关文章推荐
- oracle10g- oracle数据语言 常用函数 日期格式
- Oracle常用日期数据格式
- Oracle常用函数(字符串、数据类型转换、日期类型)
- oracle 日期常用函數 (SYSDATE、日期格式)
- oracle trunc 函数处理日期格式
- oracle常用命令--插入/添加表数据之insert命令--插入日期
- oracle 日期转换格式 函数
- oracle 日期常用函数 (ADD_MONTHS,LAST_DAY,NEXT_DAY,MONTHS_BETWEEN,NEW_TIME,ROUND,TRUNC)
- ORACLE 常用函数——日期/时间函数
- Oracle个别日期格式在SQL Server中的转换(自定义函数)
- Oracle常用功能函数 -- 日期
- Oracle中字符型格式的日期数据查询
- ORACLE 常用函数——日期/时间函数
- 在Oracle使用sql语句中如何插入日期格式的数据
- Oracle Class2. SQL查询和SQL函数(Oracle数据类型,ddl,dml,dcl,事务控制语言tcl,sql操作符,sql函数,select语句,运算符,分析函数,临时表)
- sql 日期常用函數 (SYSDATE、日期格式) oracle
- 解决带有日期格式的txt数据导入oracle报错的问题
- ORACLE 两个表或两个结果集的数据对比常用的函数
- Oracle数据库(Oracle存储结构、Oracle运行机制、日期相关的函数、序列、大对象数据类型、表的修改与约束、事务)
- oracle trunc 函数处理日期格式