Getting Started with ASP.NET MVC - Part 6: ASP.NET MVC and Entity Framework
First Time? You can support us by signing up. It takes only 5 seconds. Click here to sign up. If you already have an account, click here to login.

Where can I find the script to generate the "Tally Table"?

Oct 26 2011 12:59PM by Jacob Sebastian   

A Tally Table (also known as Number Table) is an essential tool that every database administrator like to have in their databases. Such a table helps to solve a number of PLSQL problems in a SET based manner. Waldar provided a PLSQL script to generate 1 million row tally table.

/***********************************************************************
 Purpose:
 Create a standared "Numbers" table for use in solving PL-SQL Challenges.

 Programmers Notes:  
 1. This table contains all INTEGER values from 0 (zero)  to 1,000,000 
    inclusive and has a clustered index on the single INTEGER column 
    called "N".

 2. The table is named for the challenges so as not to overwrite 
    existing Tally or Numbers tables by accident.  Even then, if the 
    plsqlc_Tally exists, this run will fail.

 Revision History:
 Rev 00 - 18 FEB 2010 - Walder - Initial release.
***********************************************************************/
--===== If the table already exists, drop the table if you wish to re-create.
-- DROP TABLE plsqlc_Tally;


--===== Create and populate the Numbers table on the fly.     
CREATE TABLE plsqlc_Tally
(
    n number(7),
    CONSTRAINT PK_plsqlc_Tally_N
    PRIMARY KEY (N)
    using INDEX
)
organization INDEX;

INSERT INTO plsqlc_Tally (N)
SELECT LEVEL
FROM dual
connect BY LEVEL <= 1e6;

COMMIT;

0
Liked



Submit

Your Comment


Sign Up or Login to post a comment.

    Copyright © Beyondrelational.com Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising