Calculate the material database

Hi all

I'm new Oracle DBA in the industry, not a lot of experience in the database. I have some confusion. Maybe it's stupid question but this turning point in my mind. Please help to solve these.

(1) for new projects comes, I'm confusing all cache/RAM required and CPU. Although I can calculate the capacity of the hard drive.  for example - my Application user say we have total TPS (transactions per second) is 1000 (200 update, delete 300, 100 and 200 insertion selects), so in this case how can I calculate hardware capacity, and how I can answer for them.

(2) this is the reverse of the first question.  Suppose a database running, and everything works fine. I want to calculate the GST (transactions per second). means how select/update/insert/delete running in the second. How to calculate or identified TPS.

Thanks in advance...

Reg,

Hard

Thank you all, I got my answer...

Oracle Capacity Planning

Introduction - Database management

The best way to perform the Oracle capacity planning is with planningsof the worksheet of the ability of the Oracle. Database management has increased over the years to the simple management of a few tables and indexes to a complex of interlocking responsibilities ranging from management of objects of database to participate in decisions large enterprise on hardware, software and development tools.

In order to fully discharge these functions the modern Oracle DBA needs one big together skills. In the last hours, we will discuss the skills needed, and specifically how they apply to an Oracle DBA.

Capacity planning system

In a green field operation (the one where you're here in front of the equipment and the database), a DBA will have a critical role to play in planning and configuration of the new system. Even in existing environments the ability to predict new servers, new databases, or improvements to existing databases and systems is crucial.

Essentially the DBA should be concerned with two main questions:

  1. Get enough server to ensure an adequate return
  2. Sufficient backup and power of recovery for backup and restoration carried out respecting the time constraints required.

All this is actually under the heading planning resources and capabilities. Resources and capacity planning Oracle is a database intensive resources system. The more CPU, memory and disk resources, you can provide Oracle, better it performs. Planning with Oracle resources becomes more a game of "How can we afford to buy" instead of "what is the minimum configuration. A minimally configured Oracle server won't work effectively. Specification of resource for Oracle In the specification of resources, there are several questions that should be answered.

  1. How many users will use the system today and in the future?
  2. Data will include the system contain both now and in the future, we don't know the growth rate?
  3. What response time are expected?
  4. The availability of this system is planned?

Why are these issues important?

  1. How many users will use the system today and in the future?

This issue is important, because it effects how much processing power is going to be necessary. The number of users will determine the number and speed of the processors, memory, the related network configuration size.

  1. Data will include the system contain both now and in the future, we don't know the growth rate?

This issue is important because it determines the disk needs, how much storage will need to take the data we have today and how it will be necessary for the growth. The answer to this question also allows to determine how much memory will be needed.

  1. What response time are expected?

This question is important because it pushes the number, type and speed of CPU resources, but also of network problems. He will lead also issues such as the number and speed disk configuration disks, number and speed of the controllers, disk partitioning decisions.

  1. The availability of this system is planned?

This question is important because the availability of the system grows the type of RAID (1, 0, 0/1, RAID5) configuration, the type of scheduled backup (cold, warm) and parallel server problems. Requirements change if all that is expected is the system to be available during business hours from Monday to Friday, or if the system is supposed to be available 24 X 7 seven days a week. This also leads the type of backup media, be it a single tape drive is all that is necessary or is it a hi-speed, tape-stacker, multichannel, solution based silo?

To properly perform a capacity planning cooperative efforts should be made between system administrators, database administrators, and network administrators.

Step 1: Size of the Oracle database

A starting point for the whole process of capacity planning is to know how many and what size, databases will be based on a given server resource. The physical size of the tables, indexes, clusters, and LOB storage areas will play an essential role in the sizing of the overall database, including areas of shared global memory and disk farm. DBAS and developers must work together in order to properly size the physical files of the database. The design of the database will also lead the placement and the number of storage spaces and other resources of database such as the size and quantity of newspapers of recovery, rollback segments and their associated buffers.

Typically areas of buffer of data to an LMS database block size out to between 1/20 to 1/100 the physical sum relative to the total number of database file sizes. For example, if the physical size of the database is 20 gigabytes the database block buffers should on about 200 megabytes to 1 gigabyte in size depending on the how the data is used. In most cases the LMS shared pool would be size out to about 20-150 megabytes maximum according to the usage model for the common areas of SQL (see next lesson). For a system of 20 gigabytes the redo logs would most likely run between 20 and 80 megabytes, you want mirrored volumes and probably not less than 5 groups. The pad of paper to support a 50 megabyte redo log file would be a minimum of 5 megabytes may be as large as 10 megabytes. The last major factor for BMG would be the size of the sorting box, for this size of a database, a sort of 10 to 20 megabytes field is on the right (according to the number and size of all kinds). Remember that sort areas can be a part of the shared pool or a part of the large pool, so we'll cover in a future lesson.

So on that basis we've determined? Gives a choice of 400 megabytes for our size memory buffer of data block, 70 megabytes for the shared pool, buffers of the newspaper of 4 to 10 MB (40 MB) and a size of 10 megabytes sort field. We look at a megabyte of 500-600 LMS with the important factors of non - DBA added in. Since you are not supposed to use more than 60% of the physical memory (according to the interviewee) it means w will need at least a gigabyte of RAM. With this size of database a single UC probably won? t give enough performance so we are probably looking at least a 4-processor machine. If we have more than one instance installed on the server, the memory requirements will increase.

Step 2: Determine the number and Type of users:

Of course, a database of a user will require fewer resources than the user database of a thousand. Generally, you will need to take a LOOT at how many memory resources and drive each user will need. An example would be to assume that a user installed 1,000 users base, only 10 percent of them at the same time will use the database. That leaves 100 concurrent users, those who perhaps a second 10 percent will do the activity requiring sorting areas, this brings the number up to 10 users each use (in our previous example) 10 megabytes of memory each (100 MB). In addition each of the 100 users simultaneous need about 200 k of space (depending on the activity, BONE, and other factors) process so there is an additional charge of 20 megabytes just for the user process space. Finally, each of these users will require probably some amount of disk resource (or less if they are client-server or web-based) let? s give them 5 meg of disk to start each, which adds up to 5 gigabytes of disk (give or take a meg or two.)

Step 3: Determine the hardware requirements for the required response time meet and support of user Support:

This step is the system administrator and maybe the seller of equipment. Given our mix of 1000:100:10 users and any required response time numbers, they should be able to configure a server that will obtain good results. Usually, this will require several, interfaces multi-lane disks and several separate physically the drive bays.

Step 4: Determine the material backup to support the requirements of availability required:

Here again the admin system and hardware vendor will have a helping hand in the decision. Based on the size of the disks and the speed of the maximum recovery time backup solution should be developed. If there is no way to meet your requirements of availability required using backup schemas simple more esoteric architectures can be specified as strips of multiple channels, hot databases in standby or even Oracle Parallel Server. Let? s say we need a requirement of availability 24 X 7 with instant failover (no recovery time because of the critical nature of the mission of the system). This type of specification would require Oracle Parallel Server in a configuration of automated failover. We also use either a double or triple mirror on disk so that we could divide the mirror to perform backups without losing the protection of mirroring.

Let? s compile what we have determined so far:

Material: 2-4 CPU (for higher-speed CPU we can) with at least 1 gigabyte (preferably 2) of RAM shared, at least 2 disk controllers each with many channels, 90 gigabytes of disk resource using a three way mirror to give us a matrix to mirror a triple 30 concert. The systems themselves should have a sufficient internal disk subsystem to support the operating system and the swap and the requirements of pagination. Systems must be able to share the disk resources so should support clustering. High-speed tape backup to minimize the folding times mirror.

Software: Oracle Parallel Server, Cluster, the network management software, software backup management software to support backup material.

Capacity and resource planning is not an exact science. Basically, look for a moving target. Dual Pentium II 200 NT Server with 10 GB of 2 GB SCSI disks for $5 k, I bought 2 years ago has a modern equivalent in the Pentium III 400 with the builtin 14 concert my father-in-law just bought for $1 k. At the time where we specify and purchase of a system, it is already replaced. You should insist on power substitute options more effective, more inexpensive they are available during the phases of specification and procurement.

Reg,

Hard...

Tags: Database

Similar Questions

  • Formula to calculate the SGA for 12 c of OLTP database

    Dear Experts,

    What is the formula to calculate the SGA for an OLTP database application.

    This will surely depends on several variables such as

    (1) the maximum number of connections application would have

    (2) growth of database

    • users connected
    • Server connections
    • total number of connections
    • connection memory
    • OS/application memory

    Thanks John.

    Is below the formula makes no sense?

    Why thank me when you don't know what I said:

    You will not find a formula.

    You formula has nothing to do with the numbers suggested for EBS, which could (only "might") be a reasonable starting point. You have not given any indication of how you arrive at these figures. You just apply that 80% of the RAM formula suggested by Mr. Faruq? If so, you might want to ask him how he justifies the algorithm.

    One point, that you should study management PGA. Your formula assumes that all connected sessions required 30 MB of RAM, all the time. How can you come to this conclusion? On your development system, you can observe how PGA is necessary for the optimal performance of your queries. Then you can ask "how many sessions is actually running a query at the same time?", adds on the non-negotiable PGA by session and calculate the requirement on the PGA TOUR as a result. You should also think about what you call ""memory connection ' and what you call 'PGA Pool'. " These aren't words that I know.

  • How do we calculate the growth of the database?

    I have the situation where I have to calculate the growth of the database. I'm new to this business. We have implemented new indexes on the database of production where it took freespace all that remains. So, we have increased tablespace because we still have a few clues more to compile. Unfortunately, we ran out of space on the server. I asked for more space on the server that is to say 50% of the current database size. Of course, there are other databases on the same server and management wants to know why I need that a lot of space. Now my question is

    1. How do we calculate the growth of the database?
    2. How do we know how much table space is necessary for the given index.
    3. while maintaining growth increased from DB in calculating how we predict future growth.

    Any help much appreciated. Thank you.

    Hello

    Please visit the following link.

    http://www.DBA-Oracle.com/t_database_growth_reports.htm

    I hope this will help you.

    Thank you

  • is this allowed? materialized view the log for the remote database (via db lin

    : Hi guys.

    try to do

    create materialized view log on user@xxx with sequence, rowid (col1, col2), including the new values;


    where xxx is a remote db link
    ------

    had this error

    ORA-00949 - illegal reference to the remote database

    Google but do not know whelther this error is an internal error or not allowed for mviews characteristic.

    help pleaase!

    Rgds,
    Noob

    do you mean that the materialized log should be created in the same location where the main table

    YES. Of course, it must be there! Any update to the main table should also update the MV log that is created against it!

    Hemant K Collette

  • Calculate the space used in the database!

    Hi all

    I can calculate the space used by using one of the following ways:

    1. determine the size allocated by issuing

    SELECT SUM(d.bytes/1024/1024/1024)
    FROM dba_data_files;

    2 calculate the free space by issuing

    SELECT SUM(bytes/1024/1024/1024)
    from dba_free_space;

    Space used will be the value of the first statement - value of the second statement. This is manually!

    Is it possible to combine these two queries?

    Thank you!

    Dan.

    You can certainly combine queries

    SELECT (allocated.bytes - free.bytes )/1024/1024/1024 used_gb
      FROM (select sum(bytes) bytes from dba_data_files) allocated,
          (select sum(bytes) bytes from dba_free_space) free
    

    Normally, you could group tablespace as well.

    But if you want just the amount of space used, it is probably easier to just

    SELECT sum(bytes)/1024/1024/1024 used_gb
      FROM dba_segments
    

    Justin

  • Recommendations/suggestions for the material?

    Hi all

    I'm a little confused with what LabVIEW Embedded will work with. I read http://zone.ni.com/devzone/cda/tut/p/id/7066 , but that was not very useful because it tells me there are 260 aircraft but it lists only the 3 level 1 section (I guess that there are more than three). A research in the community gave no results. In the level 2 section, they are pointing to the keil device database, but it doesn't really help me either.

    I'm looking for a hardware platform like this http://www.gumstix.com/store/catalog/product_info.php?products_id=252 or this http://www.compulab.co.il/x270em/html/x270-em-datasheet.htm that will work with Embedded LV. I really don't want to design and build the hardware from scratch - I want to find something that will work for me for prototyping on shelf and it will also work for the small volumes of product.

    The problem is, how do I find something like that? Does anyone have the hardware recommendations? The cards Gumstix has an ARM A8 processor so I think he might be targeted by Embedded LV but I don't know. There is a post on this forum regarding the cards Gumstix but it refers to the microprocessor LV SDK and the replies to this post, it seems a very complicated if the process is impossible to implement the programming of LV on it. However, this post is old, and I understand that the SDK is no more.

    Any notice received with gratitude.

    Dr. Phil

    Hi Phil,

    As the Manu says, the best of the material of the plate for use with LabVIEW Embedded for ARM module are MCB2300, MCB2400, LM3S8962 Evaluation Committee.

    If I had to do your project, I probably used this material:

    Stellaris® Single Board Computer display Intelligent Module RDK

    LM3SXXXX family is easier to port of LabVIEW that family CAP because it uses pilot Stellaris.

    In addition, this material comes with examples that work on Keil µVision.

    However, you must create a new target and adds all the new features of LabVIEW. It can be difficult at the beginning.

    Best regards

  • Trigger on the materialized view

    Hello

    I have the scenario based (Database 11 g):

    There is a view materialized (PERSON), which contains the ID and NAME fields. This MV is update daily with a fast refresh.

    I have a second array (NAMES), with ID and NORM_NAME. This table contains the name of the person, without special characters.

    For example, for recording / * 1 BJORN * / in the PERSON table

    I would check * 1 BJORN * / in table NAMES.


    Problem is how to fill the NAME table after the filling of the materialized view.

    I used a trigger AFTER INSERT or update, as described below, but even if I update the master table (for this purpose, update the MV), I have only to trigger inserts.


    Is there a way to implement a trigger "after update" on a materialized view, or do I need another approach?


    /*


    create or replace TRIGGER TRG_TESTE_MV

    AFTER INSERT OR UPDATE ON THE PERSON

    REFERENCING OLD AS OLD AGAIN AS NEW

    FOR EACH LINE

    BEGIN

    IF THE INSERTION

    INSERT THE NAMES

    VALUES

    (: NEW.id,:NEW.NAME);

    END IF;

    IF THE UPDATE CAN

    UPDATE OF NAMES

    SET NAME =: NEW.NAME WHERE ID =: NEW.id;

    END IF;

    END;

    */

    Thanks for any help

    Your trigger fires, but I doubted that you will be satisfied with the results. You really need to understand how to refresh process works before you begin creating triggers of MV:

    SQL > create table emp1 in select * from EMP
    2.

    Table created.

    SQL > create materialized view emp1 with rowid journal
    2.

    Materialized view log that is created.

    SQL > create materialized view emp1_mv
    2 fast refresh
    3 on request
    4 with rowid
    5 as
    6 select * from emp1
    7.

    Materialized view created.

    SQL > create or replace
    trigger 2 emp1_mv_biudr
    3 before inserting
    4 or update
    5 or delete
    6 on emp1_mv
    7 for each line
    Start 8
    9 insert then dbms_output.put_line ('INSERT' |: new.ename); end if;
    10 if the deletion then dbms_output.put_line ('REMOVE' |: old.ename); end if;
    11 end;
    12.

    Trigger created.

    SQL > insert
    2 in emp1 (empno, ename, sal)
    3 values(1,'X',1000)
    4.

    1 line of creation.

    SQL > validation
    2.

    Validation complete.

    SQL > set serveroutput on
    SQL > exec dbms_mview.refresh ('emp1_mv', 'f');
    INSERTION OF X

    PL/SQL procedure successfully completed.

    SQL > update emp1
    2 set sal = sal + 1
    3 where ename ('King', 'JONES')
    4.

    2 lines to date.

    SQL > validation
    2.

    Validation complete.

    SQL > set serveroutput on
    SQL > exec dbms_mview.refresh ('emp1_mv', 'f');
    INSERTION OF JONES
    INSERTION OF KING

    PL/SQL procedure successfully completed.

    SQL > delete emp1
    2 where in ename ('ALLEN', 'SMITH')
    3.

    2 deleted rows.

    SQL > validation
    2.

    Validation complete.

    SQL > set serveroutput on
    SQL > exec dbms_mview.refresh ('emp1_mv', 'f');

    PL/SQL procedure successfully completed.

    SQL >

    As you can see, refresh MV updates ever. Results update underlying table to remove/insert in MV. That's why your trigger will not give the results that you expected.

    SY.

  • Calculate the sum of the duration stored in format HH24

    Dear professionals,

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production. I stored length of certain events in the table TIME_DURATION as as follows (format h24:mi):

    CREATE TABLE "TIME_DURATION" ("ID" NUMBER(11,0), "HOURSMINUTES" VARCHAR2(5));
    
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('5','00:55');
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('7','00:18');
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('9','06:34');
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('15','00:12');
    Insert into TIME_DURATION (ID,HOURSMINUTES) values ('17','09:50');
    INSERT INTO TIME_DURATION (ID,HOURSMINUTES) VALUES ('41','12:39');
    

    select * from time_duration;
    
            ID HOURS
    ---------- -----
             5 00:55
             7 00:18
             9 06:34
            15 00:12
            17 09:50
            41 12:39
    
    6 rows selected.
    

    Now, I want to calculate the total time for all events (sum of all specific times). In this case, it should be 30 hours and 38 minutes.

    Any help would be much appreciated.

    Thanks in advance.

    Hello

    So, you want to add a number of lines varibale.  This sounds like a job for the SUM function.  AMOUNT of work on numbers, no channels such as time, so use TO_NUMBER to convert strings to numbers, so you can add them.  If you want to display the result as a string, you can use TO_CHAR to convert the sum into a string.

    WITH got_total_minutes AS

    (

    SELECT SUM ((TO_NUMBER (SUBSTR (heure, 1, 2) * 60)))

    + TO_NUMBER (SUBSTR (hour 4))

    ) AS total_minutes

    OF time_duration

    )

    SELECT TRUNC (total_minutes / 60). ':'

    || To_char (MOD (total_minutes, 60))

    , "FM00.

    ) AS total_hours_minutes

    OF got_total_minutes

    ;

    The output is not quite what you asked:

    TOTAL_HOURS_MINUTES

    --------------------

    30: 28

    If you really want 30:38', explain how to get it.

    This solution assumes that time always is always 5 characters (2 digits, a separator and another of 2 digits) as it is in your sample data.

    If your actual data aren't like your sample data, the same approach still works, but the SUBSTR expressions will be more complicated.

    adnanBIH wrote:

    Dear professionals,

    I use Oracle Database 11 g Enterprise Edition Release 11.2.0.4.0 - 64 bit Production. I stored length of certain events in the table TIME_DURATION as as follows (format h24:mi):

    1. CREATE TABLE 'TIME_DURATION' ('ID' NUMBER (11.0), VARCHAR2 (5)) 'HOUR '.
    2. Insert into TIME_DURATION (ID, TIME) values ('5',' 00:55 ');
    3. Insert into TIME_DURATION (ID, TIME) values ('7',' 00:18 ');
    4. ...

    Thanks for posting the CREATE TABLE and INSERT.

    ID is a NUMBER, so do not use quotes around it:

    Insert into TIME_DURATION (ID, TIME) values (5, ' 00:55 ');

    Insert into TIME_DURATION (ID, TIME) values (7, ' 00:18 ');

    ...

    Depending on how you plan to use the hour, you may want to store a NUMBER, also, or maybe an INTERVAL DAY TO SECOND.

  • Re: view opaque and the materialized view

    Hi Experts,

    I want some clarification of opaque and view view in the physical layer OBIEE materialized

    -> what is the main difference between the opaque view and materialized in the RPD perspective view, we have to do this at the level of the RPD or DB.

    -> I want the list of opaque opinion and materialized in the RPD view how I should do.

    -> How opaque views will degrade the performance and how a materialized view will improve performance at the level of the report.

    -> In scenarios that we use view opaque and the view materialized (if possible with a scenario for the best permanent basis).

    Thanks in advance.

    I want some clarification of opaque and view view in the physical layer OBIEE materialized

    -> What is the main difference between opaque view and create the materialized view in the RPD point of view, we have to do this at the level of the RPD or DB.

    Opaque views is a SQL statement that is defined in the physical layer, OBIEE will use all in the construction of a SQL query. In a way it's not different from a database view, except it is set in OBIEE only. Alternatively, you can deploy an Opaque view, which pushes its definition in the database. Read more about it here: work with physical tables, Cubes and joins - 11 g Release 1 (11.1.1)

    A materialized view (MV) is a database concept where the results of a SQL statement are physicalised like a table, and therefore as OBIEE is a MV is just another physical array

    -> If I want a list of the opaque views and materialized in the RPD view how I should do.

    To find opaque views, use the function «Repository of applications» administration tool Search physical Tables and set up a filter on the Type = Select

    Screenshot: https://www.evernote.com/shard/s16/sh/5c843e47-bff1-4d4b-b847-be98f3a2ec09/cf060a6cd9805f687fa0b5b46f3f0020

    To find materialized views, you will need to query the catalog in your database (for example select object_name, object_type from user_objects where type_objet = "MATERIALIZED VIEW" ;) and compare it to the list of tables in your SPR)

    -> How opaque views will degrade the performance and how a materialized view will improve performance at the level of the report.

    A materialized view is materialized, in other words, the results are already stored in the database. This means usually there will be more efficient because all the joins and aggregations, etc. will be settled in advance.

  • PL/SQL function to calculate the non-working days

    Hello

    I have the following pl/sql function which generates a number of days between two selected dates (i.e. excluding weekends). However, I also need to exclude specific holidays - day of Christmas etc. These holiday dates are stored in a table in our database (11 GR 2) called "HOLIDAY".

    How can I integrate the holidays which is held in the table of holidays in the following query to exclude these dates as well? I know how to write a separate funtion pl/sql for a number of days between two dates using SELECT... BUT I can't work out how to bring together them in a single query.

    Could someone show me how with the pl/sql / dates below please?

    Example of HOLIDAY table below.

    Thank you!

    TP

    create or replace
    function WORKING_DAYS (pi_start_date in date, pi_end_date in date) return integer
    
    is
    
    v_start_date date :=pi_start_date;
    v_end_date date:=pi_end_date;
    v_count integer:=0;
    
    begin
    
    while v_start_date <= v_end_date
          loop
                            if to_char(v_start_date,'D') not in ('6','7')                    
                            then
                            v_count := v_count+1;                       
                            end if;
                           
                    v_start_date:=v_start_date+1;
                   
          end loop;
         
    return v_count;
    
    end;
    
    

    (select '10-Apr-2013' as NWD from dual union all
    select '06-May-2013' from dual union all
    select '27-May-2013' from dual union all
    select '26-Aug-2013' from dual union all
    select '26-Dec-2013' from dual union all
    select '25-Dec-2013' from dual union all
    select '01-Jan-2014' from dual union all
    select '18-Apr-2014' from dual union all
    select '21-Apr-2014' from dual union all
    select '05-May-2014' from dual union all
    select '26-May-2014' from dual union all
    select '25-Aug-2014' from dual union all
    select '25-Dec-2014' from dual union all
    select '26-Dec-2014' from dual) HOLIDAYS
    

    Hello

    the link is on MOSC, not OTN... Here's a copy:

    This function calculates the number of days between two dates, ignoring weekends and holidays (if requested and if the holidays are stored in a table)

    I give an example of table 'public_holiday' with sample data, but users must ensure that their table contains the relevant data (all holidays within the maximum range of use of the service)

    CREATE TABLE public_holiday (calendar_day, DATE, text VARCHAR2 (30));

    FUNCTION to CREATE or REPLACE nb_days (p_date_from IN DATE

    p_date_to DATE by DEFAULT TRUNC (sysdate)

    , p_public_holidays in CHAR DEFAULT 'Y '.

    ) RETURN NUMBER

    DEFINE AUTHID

    AS

    /*********************************************************************/

    / * Author: Bruno Vroman * /.

    / * Created: 23-AUG-2012 * /.

    / * Last updated: 23-AUG-2012 * /.

    / * Object: to calculate the number of days between 2 dates, to the exclusion of * /.

    / * Saturday and Sunday, but also "holidays" If the * /.

    / * argument 'p_public_holidays' = 'Y ' * /.

    / * Support: p_date_from<= p_date_to                             ="">

    / * component ' hour min dry "ignored (just counting days) * /.

    /* First step:                                                       */

    / * the calendar days between 2 days * /.

    / Remove 2 days for each "week" and 0 or 1 extra day * /.

    / * function to a condition "complex" mix day of first week * /.

    / * and the number of days when full remaining weeks are removed * /.

    / * (set up once for all, for example if there is 3 days and the * /)

    (/ * first day is a Thursday, there is 1 "Sat/Sun" to subtract) * /.

    / * Second step: If 'p_public_holidays' = 'Y': other * /.

    / * days, do not count holidays.                         */

    / Holiday everyday are defined in a table "public_holiday" * /.

    / * Note: there may be holidays defined on Saturday/Sunday.       */

    /*********************************************************************/

    l_result NUMBER;

    l_from DATE;

    l_to DATE;

    l_case tank (4);

    BEGIN

    l_from: = TRUNC (p_date_from);

    l_to: = TRUNC (p_date_to);

    l_case: = TO_CHAR (l_from, 'Dy', 'NLS_DATE_LANGUAGE = English').

    To_char (MOD (l_to - l_from + 1, 7));

    l_result: = l_to - l_from + 1

    -TRUNC ((l_to-l_from + 1) / 7) * 2

    -CASE

    WHEN l_case IN ('Mon6', 'Tue5', 'Wed4', 'Thu3', 'Fri2'

    , "Sat1", "Sun1", "Sun2', 'Sun3", "Sun4".

    , "Sun5', 'Sun6.

    )

    THEN 1

    WHEN l_case IN ('Tue6', 'Wed5', 'Wed6', 'Thu4', "Thu5"

    , 'Thu6', 'Fri3', 'Fri4', 'Fri5', 'Fri6 '.

    , "Sat2", "Sat3', 'Sat4', 'Sat5", "Sat6.

    )

    THEN 2

    0 OTHERWISE

    END

    ;

    IF SUPERIOR (p_public_holidays) = "Y".

    THEN

    SELECT l_result - COUNT (*)

    IN l_result

    OF public_holiday p

    WHERE p.calendar_day > = l_from

    AND p.calendar_day<=>

    AND SUBSTR (TO_CHAR (p.calendar_day

    , "Dy".

    'NLS_DATE_LANGUAGE = English'

    )

    , 1, 1 ) != 'S'

    ;

    END IF;

    RETURN l_result;

    EXCEPTION

    WHILE OTHERS

    THEN

    DBMS_OUTPUT. Put_line (' CTF nb_days (' |))

    To_char (p_date_from, "MON-DD-YYYY"). ', ' ||

    To_char (p_date_to, "MON-DD-YYYY"). ', ' ||

    p_public_holidays | ' ) : ' || SQLERRM

    );

    LIFT;

    END nb_days;

    /

    REM

    REM example:

    REM A) fill out the 'public_holidays '.

    REM

    TRUNCATE TABLE public_holiday;

    INSERT INTO public_holiday VALUES (DATE ' 2012-01-01', ' new year (a Sunday)');

    INSERT INTO public_holiday VALUES (DATE '' 2012-01-03, "for example");

    REM (insert other days...)

    COMMIT;

    Call the function for some pairs of dates of REM B)

    REM nb1: remove only Sat/Sun

    REM nb2: also remove holidays

    REM

    ALTER SESSION SET nls_date_format ='Dy DD-MON-YY';

    WITH some_dates AS

    (SELECT DATE ' 2011-12-29'd dual FROM

    UNION ALL SELECT DATE ' 2012-01-08' FROM dual

    UNION ALL SELECT DATE ' 2012-01-10' FROM dual

    )

    SELECT d1.d 'FROM '.

    , d2.d ' to THE '.

    , nb_days (d1.d, d2.d, ' don't) nb1

    , nb_days (d1.d, d2.d, 'Y') nb2

    OF some_dates d1

    some_dates d2

    WHERE d1.d<=>

    ORDER BY nb1, nb2, d1.d

    ;

    GO TO NB1 NB2

    ------------- ------------- ---- ----

    Monday, January 8, 12 Monday, January 8, 12 0 0

    Friday, December 29, 11 Friday, December 29, 11 1 1

    Wednesday, January 10, 12 Wednesday, January 10, 12 1 1

    Monday, January 8, 12 Wednesday, January 10, 12 2 2

    Friday, December 29, 11 Monday, January 8, 12 7 6

    Friday, December 29, 11 Wednesday, January 10, 12 9 8

    Hope that this could be useful, but note that this code has not been completely tested, so check and test before you trust it (in the case of any questions, please post a comment)

    Bruno Vroman.

    Best regards

    Bruno

  • Reg: Export data of the physical database system standby.

    Hi all

    We have a standard edition one 11 GR 1 material oracle environment, I need to export the data from the physical monitoring system.

    If anyone can suggest me, how to do it safely (up state).

    Kind regards

    Konda.

    Oracle Data Guard is available only as a feature of Oracle Database Enterprise Edition. It is not available with Oracle database Standard edition.

    Then you must export data only from primary or you use EXP instead of EXPDP on the standby database. Because EXPDP create a temporary table export process duration.

    Concerning

    Mr. Mahir Quluzade

  • Process of calculation to calculate the value after submit after all validations

    Hello

    Please help with a possible approach or suggestions for the calculation process.

    I have a calculation process after submit I want to calculate its value after that all validations are handled. Because this process of calculating trim is off of the first part of the input string of the user for the P3_USES element. Thus, for example consider; the user selects a value for P3_USES (point list manager) to be "TAC"... BCA... BCA... BCA... 0.CA BC... "CA IT BC. So my calculation process just stripes off the coast of the first portion of the string and computes the value will be "BCA"... BCA... BCA... 0.CA BC... "CA IT BC. It works fine when all postings on the page are placed without cooking.

    The problem occurs, then the validation fails on the form. Once the validation fails, the calculation process; already calculates the value and the P3_USES value form element is set to "BCA"... BCA... BCA... 0.CA BC... "CA IT BC. So, here the user solves the problem of validation and sends it again the form, but at this point the value is calculated again but this time that my string is "BCA"... BCA... BCA... 0.CA BC... CA IT BC"which is not correct, because my initial user string entry was"TAC"... BCA... BCA... BCA... 0.CA BC... "CA IT BC.

    So my question is how they treat the value of my calculation after all validations. While I can keep the original value of the P3_USES element. I'm using the version of Oracle APEX 4.0 and Oracle 10 g R2 database.

    Thank you

    Rambeau

    Hello

    Combine code of calculation and validation?

    Perform the calculations in the process?

    Use another element to contain the value 'real '?

    Kind regards

    Jari

  • Try to calculate the size of the PAGE file

    This is an academic exercise. I am trying to determine why my PAGE file size is what it is. Currently, he is registered to 28,000,331 bytes. (He's alone). Here are the facts:

    3 dense dimensions, stored members are 17 * 20 * 5, for a total of 1,700 * 8 = 13 600 bytes.

    The actual maximum blocks are 19 800. The maximum reported are 24 750.

    I have disabled compression for ease of calculation.

    There is only 1 block no missing.

    I use SER60 as my guide in the section estimate disk and the memory required. However, when I use the planned calculation:

    Number of blocks * (size of data block expanded + 72 bytes)

    I don't get anywhere near the number of bytes listed for the PAG file. I realize that I am not to mention the rest of the database files and do not know if this calculation is only for the PAG files or all files. I am not very interested in the size of the entire database, just the file PAG. So my questions are:

    1. is the calculation provided for all files or just the file PAG?

    2. If the answer to 1 is Yes, is there a separate calculation, that I can use to determine the size of the PAGE file only?

    Take a look at NUMBLOCKSTOEXTEND in the technical reference on Essbase.  We had a long conversation that addressed this issue on Network54 recently: http://www.network54.com/Forum/58296/thread/1374608752/11-1-2-2+Fragmentation

    Short answer is that Essbase allocates file space .pag in 2048-block pieces, which is the default value of NUMBLOCKSTOEXTEND 11.1.2.2.  Calculate how many blocks (including header block 72 bytes) integrate 28,000,331 bytes and you will see that this is almost exactly 2048.

    With compression on it more difficult (for me, at least) to understand how Essbase arrives with the size of the average disk blocks to use as the size on the disk with compression on is not constant.

  • Function to calculate the Minutes of business between two Dates

    Hello

    I use the version of database Oracle 11.2.1. I would like to calculate the number of minutes of work between the two dates where working hours are Monday - Thursday from 08:45 to 17:00 and Friday from 08:45 to 16:30

    I found the following function useful in a similar position but wanted help picking up the days and the hours above into account

    CREATE OR REPLACE
      FUNCTION get_bus_minutes_between(
                                       p_start_date DATE,
                                       p_end_date DATE
                                      )
        RETURN NUMBER
        IS
            v_return NUMBER;
        BEGIN
            with t as (
                       select  case level
                                 when 1 then greatest(p_start_date,trunc(p_start_date) + 9 / 24)
                                 else trunc(p_start_date) + level - 15 / 24
                               end start_dt,
                               case connect_by_isleaf
                                 when 1 then least(p_end_date,trunc(p_end_date) + 18 / 24)
                                 else trunc(p_start_date) + level - 8 / 24
                               end end_dt
                         from  dual
                         connect by level <= trunc(p_end_date) - trunc(p_start_date) + 1
                      )
            select  sum(greatest(end_dt - start_dt,0)) * 24 * 60 work_minutes
              into  v_return
              from  t
              where trunc(start_dt) - trunc(start_dt,'iw') < 5; -- exclude weekends
            RETURN v_return;
    END;
    /

    Can anyone help?

    Hello

    Think about what you do.

    sliderrules wrote:

    SELECT TO_CHAR (DATE ' 1-1-1' + business_end_time, 'HH24:MI:SS')-TO_CHAR (DATE ' 1-1-1' + business_start_time, 'HH24:MI:SS') * 24 * 60

    of time_dim

    where full_date = July 1, 2013.

    AND working_day = 'Y ';

    The following error is returned:

    ORA-01722: invalid number

    The time is converted to character reslting with this error. Is there a better way to subrtacting types of data INTERVAL DAY (1) SECOND (2) (business_end_time - business_start_time)

    To_char, as its name implies, returns a string of characters.  You say that

    TO_CHAR (...) - TO_CHAR (...) * 24 * 60

    If you ask for the string returned by the 2nd TO_CHAR be multiplied by 24.  Does make any sense to you?

    Maybe you wanted to do the subtraction first, which would be

    (TO_CHAR (...) - TO_CHAR (...)) * 24 * 60

    but still would be a mistake, because you can't subtract a string to another string (or anything else).

    .

    Last Friday, I proposed this:

    SELECT SUM (LESS (end_dt, v_end_dt)

    -Most GREAT (start_dt, v_start_dt)

    ) * 24 * 60...

    where start_dt and end_dt were the DATE in the table columns, as the value returned by TO_DATE (08 11 July 2013:45 ', "DD-Mon-YYYY HH24").

    If I understand correctly, you would store stores rather 3 columns: full_date (a DATE, where the time part is 00:00:00) as well as business_start_time and business_end_time (the two INTERVAL DAY TO SECOND).  In this case, you can modify the code above to say:

    SELECT SUM (LESS (full_date + business_end_time, v_end_dt)

    -GREATEST (full_date + business_start_time, v_start_dt)

    ) * 24 * 60...

    You can add a DATE at an INTERVAL;  the result will be a DATE.  There is no need to convert anything to a data type to the other.

  • Calculate the start and end date in Connect By - during Hirerchy changes

    / * Formatted 05/20/2013 09:53 (PS5 v5.115.810.9015) * /.



    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    Hello, can you please help me or guide me in the calculation of the dates of beginning and end to the underside of logic

    I want to calculate the Hirerchy Manager to the Agent.
    Then under query works fine and its giving me the expected results
    But when there is a change in the Hirerchy Manager or manager gets promoted
    Then I need to calculate the start date and end date.
    CREATE TABLE PERSON_DTL
    (
      SID                 VARCHAR2(10 BYTE),
      EMP_MGRS_ID         VARCHAR2(10 BYTE),
      START_EFFECTIVE_DT  DATE,
      END_EFFECTIVE_DT    DATE
    );
    
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M100', 'M107', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M101', 'M102', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('A100', 'M100', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M100', 'M101', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('05/18/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M107', 'M102', TO_DATE('05/20/2013 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M102', 'M103', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M103', 'M104', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('A101', 'M105', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    Insert into PERSON_DTL
       (SID, EMP_MGRS_ID, START_EFFECTIVE_DT, END_EFFECTIVE_DT)
     Values
       ('M105', 'M106', TO_DATE('01/01/2010 00:00:00', 'MM/DD/YYYY HH24:MI:SS'), TO_DATE('12/31/9999 00:00:00', 'MM/DD/YYYY HH24:MI:SS'));
    COMMIT;
    SELECT   CONNECT_BY_ROOT (b.sid) agent_sid,
                 TRIM (
                    LEADING ',' FROM    SYS_CONNECT_BY_PATH (b.sid, ',')
                                     || ','
                                     || b.emp_mgrs_id
                 )
                    PATH,
                 START_EFFECTIVE_DT Start_dt,
                 END_EFFECTIVE_DT End_dt
          FROM   PERSON_DTL b
         WHERE   CONNECT_BY_ISLEAF = 1
    START WITH   sid IN ('A101', 'A100')
    CONNECT BY   PRIOR b.emp_mgrs_id = b.sid
    This is the results that i am getting now.
    
    AGENT_SID    PATH                       START_DT    END_DT
    
    A100    A100,M100,M101,M102,M103,M104    1/1/2010    12/31/9999
    A100    A100,M100,M107,M102,M103,M104    1/1/2010    12/31/9999
    A101    A101,M105,M106                   1/1/2010    12/31/9999
    Results Required
    
    A100    A100,M100,M101,M102,M103,M104    1/1/2010    5/18/2013
    A100    A100,M100,M107,M102,M103,M104    5/20/2013   12/31/9999
    A101    A101,M105,M106                   1/1/2010    12/31/9999

    WITH the CLAUSE will make it readable

    SQL> with paths as
      2  (
      3        SELECT   CONNECT_BY_ROOT (b.sid) agent_sid,
      4                 TRIM (
      5                    LEADING ',' FROM    SYS_CONNECT_BY_PATH (b.sid, ',')
      6                                     || ','
      7                                     || b.emp_mgrs_id
      8                 )
      9                  PATH,
     10                 START_EFFECTIVE_DT Start_dt,
     11                 END_EFFECTIVE_DT End_dt,rownum rn
     12        FROM   PERSON_DTL b
     13        START WITH   sid IN ('A101', 'A100')
     14        CONNECT BY   PRIOR b.emp_mgrs_id = b.sid
     15  ),
     16  flagged as
     17  (
     18      select agent_sid,
     19             path,
     20             start_dt,
     21             end_dt,rn,
     22             case when path like lag(path) over(order by rn)||'%' then 0 else 1 end flg
     23      from paths
     24  ),
     25  summed as
     26  (
     27      select agent_sid,path,start_dt,end_dt,
     28             sum(flg) over(order by rn) sm
     29      from flagged
     30  )
     31  select agent_sid,max(path) path,max(start_dt) start_dt,
     32         min(end_dt) end_dt
     33  from summed
     34  group by agent_sid,sm
     35  order by agent_sid;
    
    AGENT_SID  PATH                                     START_DT  END_DT
    ---------- ---------------------------------------- --------- ---------
    A100       A100,M100,M101,M102,M103,M104            01-JAN-10 18-MAY-13
    A100       A100,M100,M107,M102,M103,M104            20-MAY-13 31-DEC-99
    A101       A101,M105,M106                           01-JAN-10 31-DEC-99
    

Maybe you are looking for