Posts Tagged ‘SQL’

Oracle INFORMATION_SCHEMA

From the Database Geek.

Part of the ANSI SQL standard calls for an INFORMATION_SCHEMA. This schema contains a standardized data dictionary that is (or is supposed to be) common across various databases. Most database vendors offer a native data dictionary and a sub-set INFORMATION_SCHEMA (called info schema from this point on). Oracle is the only major database vendor (that I know of) that doesn’t even offer a subset of the info schema.

Oracle’s data dictionary (especially if you include the V$ views in that) is the most robust of all the databases I have used.

Click to continue reading “Oracle INFORMATION_SCHEMA”

Read the rest of this entry »

Calculating Business Days and Business Days Between

From the Database Geek.

I recently had a requirement to populate the day dimension of a data mart (I won’t put all of the code here as it’s pretty large). That’s not that big deal but part of the requirement was to set several columns: BUSINESS_DAY_FLAG, BUSINESS_DAY_NO and BUSINESS_DAYS_REMAINING_NO.

  • The BUSINESS_DAY_FLAG is Y is the date is MON-FRI and N is the date is SAT or SUN.
  • BUSINESS_DAY_NO is the business day of the month. There are 5 business days per week so if the month started on a monday, the second monday would be business day 6.
  • BUSINESS_DAYS_REMAINING_NO is the number of business days remaining in the month.

Click to continue reading “Calculating Business Days and Business Days Between”

Read the rest of this entry »

Group By Grouping Sets

Posted by the Database-Geek.

Summary Totals Using SQL

Have you ever needed to get totals for different combinations of columns in the same query? Did you ever want to create a nice little report from a simple SQL statement? Here’s a tip that can make your life a lot easier when you need it. The great thing about this is that you can use it in a ref cursor called from other programming languages and reduce the number of calls you need to make to the database.

Let’s say you are running queries against the Employees table of the sample HR schema provided by Oracle.

SQL> SELECT count(*) FROM Employees;

  COUNT(*)
----------
       107

Now, we want to get a total of salaries for each job in each department.

Click to continue reading “Group By Grouping Sets”

Read the rest of this entry »

XML in the Database: A Brief Overview

Oracle provides a lot of XML functionality in the database. This entry will cover the different tools Oracle provides and future entries will get into the details of each.

The three primary XML tools that oracle provides are: XML Developers Kit (XDK), XML DB and SQL Extensions for XML (SQLX and XMLType). Below is a definition of each.

XDK

The XDK is a complete XML development toolkit that was introduced for 8i. I think the first version was labeled XDK9i but the toolkit actually was available for 8i. I remember using the beta product.

Click to continue reading “XML in the Database: A Brief Overview”

Read the rest of this entry »