oracle cast() 函数问题
oracle cast() 函数问题
SQL> create table t1(a varchar(10));
Table created.
SQL> insert into t1 values ('12.3456');
1 row created.
SQL> select round(a) from t1;
ROUND(A)
----------
12
SQL> select round(a,3) from t1;
ROUND(A,3)
----------
12.346
SQL> select cast(a as int) from t1;
CAST(AASINT)
------------
12
SQL> select cast(a as number(8,4)) from t1;
CAST(AASNUMBER(8,4))
--------------------
12.3456
=========================================================
cast 是进行类型转换的, 可以针对各种Oracle数据类型. 修改的是用户的数据类型.
round只是修改的数据显示格式. 对数据做四舍五入. 类似的函数还有ceil(取此数据的最小整数). trunc( 取整函数.)
复制内容到剪贴板
代码:
SQL> select round(12.45) round,trunc(12.45) trunc,ceil(12.45) ceil
2 from dual
3 /
ROUND TRUNC CEIL
---------- ---------- ----------
12 12 13
SQL> select round(12.54) round,trunc(12.54) trnc,ceil(12.54) ceil
2 from dual
3 /
ROUND TRNC CEIL
---------- ---------- ----------
13 12 13
相关文档:
对于外连接,Oracle中可以使用“(+)”来表示,9i可以使用LEFT/RIGHT/FULL OUTER JOIN,下面将配合实例一一介绍。
1. LEFT OUTER JOIN:左外关联
SELECT e.last_name, e.department_id, d.department_name
from employees e
LEFT OUTER JOIN department ......
如果查询整库的话得以DBA权限查询数据字典dba_tab_columns
非DBA用户只能查看自己有读取权限的表
可以这样写查询
select owner, table_name
from dba_tab_columns
where lower(column_name)='firstname';
查询出哪些表包含firstname字段以及这些表属于哪个用户
注:dba_tab_columns是一个属于SYS用户的一个View ......
oracle 多表删除 同时删除多表中关联数据
2009-04-27 14:40
1、从数据表t1中把那些id值在数据表t2里有匹配的记录全删除掉
DELETE t1 from t1,t2 WHERE t1.id=t2.id 或DELETE from t1 USING t1,t2 WHERE t1.id=t2.id
2、从数据表t1里在数据表t2里没有匹配的记录查找出来并删除掉
DELETE t1 from t1 L ......
先看一段ORACLE官方文档
http://download-west.oracle.com/docs/cd/B10501_01/server.920/a96520/analysis.htm#25806:
FIRST/LAST Functions
The FIRST/LAST aggregate functions allow you to return the result of an aggregate applied over a set of rows that rank as the first or last with respect to a ......