Oracle取整的函数
摘要:1.取整(大) select ceil(-1.001) value from dual 2.取整(小) select floor(-1.001) value from dual 3.取整(截取) select trunc(-1.002) value from dual 4.取整(舍入) select round(-1.001) value from dual
阅读全文
Traversing the Dept Security tree
摘要:We can use the connect by prior function provided by Oracle to traverse the Dept security Tree . Suppose an Organization has 7 levels in Dept tree i.e. 1 to 7 .We want to traverse the dept tree from l...
阅读全文
Database Table Space Statistics
摘要:An SQL to help gathering storage tablespace statistics. The SQL will list all tablespace names in a particular database along with available, used and percent used storage space in MB.SELECT a.tables...
阅读全文
Oracle Group By Grouping Sets
摘要:So, what if you are only interested in totals. Well, Oracle does provide an extension to the GROUP BY clause called GROUPING SETS that you can use to generate summary information at the level you choo...
阅读全文
Oracle Group By ROLLUP-SubTotal
摘要:At normal time, you may want to have the subtotal for each region over all months, along with the total for all regions, or you may want the subtotal for each month over all regions, along with the to...
阅读全文
Decode()函数使用技巧
摘要:decode(条件,值1,翻译值1,值2,翻译值2,...值n,翻译值n,缺省值)该函数的含义如下:IF 条件=值1 THEN RETURN(翻译值1)ELSIF 条件=值2 THEN RETURN(翻译值2) ......ELSIF 条件=值n THEN RETURN(翻译值n)ELSE RETURN(缺省值)END IF· 使用方法:1、比较大小sele...
阅读全文
START WITH and CONNECT BY in Oracle
摘要:start with .. connect by clause can be used to select data that has a hierarchical relationship. Usually, it is some sort of parent child relationship like supervisor and an employee. Let’s assume we ...
阅读全文
Compare Data from the Same Table in two Different Environments
摘要:The Oracle SQL below compares table1 that has 2 key fields and 3 regular fields. Note: For the SQL below to work, your password needs to be the same in both environments. If not, then a connection usi...
阅读全文
Get Table Sizes in your Schema
摘要:If you want to see how much space your tables are taking in the database, log in to the shcema and execute this SQL. SELECT segment_name table_name, MAX (tablespace_name) tablespace_name, S...
阅读全文
Create a Database Link
摘要:In many cases you might need to compare data between tables across different databases. For example your test instance and production instance. You can easily create a database link between the 2 i...
阅读全文
Oracle Minus Operator
摘要:I find the MINUS operator very handy and use it a lot to compare tables and find out missing things. For example suppose you want to compare Table1 with Table2. If the two tables have the same layou...
阅读全文