GithubHelp home page GithubHelp logo

analytical-sql-examples's Introduction

analytical-sql-examples

The aim of this reopistory is to provide some simple code samples for Oracle's analytical SQL features, such as the following:

  • Window functions
  • Pivot/Unpivot
  • Top-N
  • SQL aggregation extensions: cube, rollup, grouping sets
  • Pattern Matching
  • SQL Model clause

To run these scripts you will need to install the Oracle Sales History schema which is included in the Oracle Database Examples download. There are full instructions on how to install the SH (Sales History) scheman in the "Database Sample Schemas" documentation. There are two ways to install the SH schema:

  1. Using the Database Configuration Assistant When you install Oracle Database with the Oracle Universal Installer, all the sample schemas are installed by default - assuming that you or your DBA selected the Basic Installation option. Selecting the sample schemas option installs all five of our sample schemas (HR, OE, PM, IX, and SH) in the database. If you choose not to install the sample schemas at that time, you can manually add them later.

  2. Manually Installing Sample Schemas If you decide not to install the sample schemas at the time of your initial database installation using DBCA, then you can also create the sample schemas manually by running SQL scripts. Install Oracle Database Examples (Companion CD, part of the media kit) to include these scripts in the demo directory under $ORACLE_HOME.

How to add the SH Schema into your database instance:

All scripts necessary to create the Sales History (SH) schema reside in $ORACLE_HOME/demo/schema/sales_history.

There is only one script to call which is sh_main.sql. This script creates all the schema objects and loads the data into the dimension and fact tables. When you run the script sh_main.sql you will be prompted for the sys password, tablespace names that you want to use, the directory for the database datafiles and the directory for storing the log file generated by the script.

If the SH schema is already installedn then the script checks for this and removes the existing schema objects and related users. After the sh_main.sql script runs successfully and the SH schema is installed, you are connected as the user SH. To verify that the schema was created, use the following command:

SQL> SELECT table_name FROM user_tables;

You can check that the following tables are present and populated with data: dimension tables TIMES, CHANNELS, PROMOTIONS, CUSTOMERS, PRODUCTS and the fact table SALES. These are the main tables used in the analytical SQL scripts.

analytical-sql-examples's People

Contributors

keithlaker avatar

Watchers

James Cloos avatar Mindaugas Zickus avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.