Linux - NewbieThis Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place!
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Introduction to Linux - A Hands on Guide
This guide was created as an overview of the Linux Operating System, geared toward new users as an exploration tour and getting started guide, with exercises at the end of each chapter.
For more advanced trainees it can be a desktop reference, and a collection of the base knowledge needed to proceed with system and network administration. This book contains many real life examples derived from the author's experience as a Linux system and network administrator, trainer and consultant. They hope these examples will help you to get a better understanding of the Linux system and that you feel encouraged to try out things on your own.
Click Here to receive this Complete Guide absolutely free.
I have a sql file for creating MV (Materialized views) in sql and also partition by using partition by range method. The sample of the code is as below:
CREATE MATERIALIZED VIEW "USER1_ADMIN"."CONTENT_METRICS_TEST_MV"
PARALLEL PARTITION BY RANGE (occurred)
(PARTITION April1 VALUES LESS THAN (TO_DATE('01-04-2009', 'DD-MM-YYYY')),
PARTITION April2 VALUES LESS THAN (TO_DATE('11-04-2009', 'DD-MM-YYYY')),
PARTITION April3 VALUES LESS THAN (TO_DATE('21-04-2009', 'DD-MM-YYYY')),
PARTITION May1 VALUES LESS THAN (TO_DATE('01-05-2009', 'DD-MM-YYYY')),
PARTITION May2 VALUES LESS THAN (TO_DATE('11-05-2009', 'DD-MM-YYYY')),
PARTITION May3 VALUES LESS THAN (TO_DATE('21-05-2009', 'DD-MM-YYYY')),
PARTITION June1 VALUES LESS THAN (TO_DATE('01-06-2009', 'DD-MM-YYYY')),
PARTITION June2 VALUES LESS THAN (TO_DATE('11-06-2009', 'DD-MM-YYYY')),
PARTITION June3 VALUES LESS THAN (TO_DATE('21-06-2009', 'DD-MM-YYYY')),
PARTITION Others VALUES LESS THAN (maxvalue))
Now, the requirement goes like this:
1. I should execute this sql with the above mentioned dates (for a quarter).
2. I have to increment the date by 10 days in each of the statements and also the partition names ( E.g. April1,April2,April3.......) to the particular month and also the date corresponding to it.
I was successfull in achieving the first requirement. But the second requirement is a bit complex one.
Can anyone please help me out in this?
Thanks for the quick reply!!
But the command only prints the date. this is not what i was looking for. The output should be as below:
(PARTITION jul1 VALUES LESS THAN (TO_DATE('01-07-2009', 'DD-MM-YYYY')),
PARTITION jul2 VALUES LESS THAN (TO_DATE('11-07-2009', 'DD-MM-YYYY')),
PARTITION jul3 VALUES LESS THAN (TO_DATE('21-07-2009', 'DD-MM-YYYY')),
PARTITION aug1 VALUES LESS THAN (TO_DATE('01-08-2009', 'DD-MM-YYYY')),
PARTITION aug2 VALUES LESS THAN (TO_DATE('11-08-2009', 'DD-MM-YYYY')),
PARTITION aug3 VALUES LESS THAN (TO_DATE('21-08-2009', 'DD-MM-YYYY')),
PARTITION sep1 VALUES LESS THAN (TO_DATE('01-09-2009', 'DD-MM-YYYY')),
PARTITION sep2 VALUES LESS THAN (TO_DATE('11-09-2009', 'DD-MM-YYYY')),
PARTITION sep3 VALUES LESS THAN (TO_DATE('21-09-2009', 'DD-MM-YYYY')),
I tried it out with a simple for loop and have hardcoded the values and replaced the older ones with the above mentioned values by sed
for line in `cat file1.sql`;
cat contentmetrics_mv_final.sql | sed "s/April/$var7/g" | sed "s/May/$var8/g" | sed "s/June/$var9/g" | sed "s/01-04-2009/$date1/g" | sed "s/11-04-2009/$date2/g" | sed "s/21-04-2009/$date3/g" | sed "s/01-05-2009/$date4/g" | sed "s/11-05-2009/$date5/g" | sed "s/21-05-2009/$date6/g" | sed "s/01-06-2009/$date7/g" | sed "s/11-06-2009/$date8/g" | sed "s/21-06-2009/$date9/g" > file2.sql
But with this for loop i have to change it every quarter which is not the requirement.
I am trying to automate the execution of the SQL as below:
1. Execute the SQL for the current quarter.
2. Mention a check in the script to check inside the fie1.sql whether the date (last entry of the date in the partition name) is greater than the current date. If true, then increment all the values as mentioned in the post#1 and execute the file2.sql. If the check is false, simple;DO NOTHING.
Can this be done in an easy way?
Hope it is not confusing :-)