Chinaunix首页 | 论坛 | 博客
  • 博客访问: 514304
  • 博文数量: 161
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1947
  • 用 户 组: 普通用户
  • 注册时间: 2007-08-25 01:20
文章分类

全部博文(161)

文章存档

2011年(44)

2010年(47)

2009年(48)

2008年(22)

我的朋友

分类: Oracle

2011-06-13 17:11:25

#include <stdio.h>
void info();
int atoi(char s[]);
int function(char Tbs_name[50],char Route_data_name[80],char Other_name[50],int Mix,int Max,int Size);
int main(int argc, char *argv[])
{
/*
argv[1] --Rbs_name
argv[2] --Route_data_name
argv[3] --Other_name
argv[4] --Mix
argv[5] --Max
argv[6] --Size
*/

int mix,max,size;
if(argc!=7)
{
     info();
     return 1;
}

mix=atoi(argv[4]);
max=atoi(argv[5]);
size=atoi(argv[6]);

if(mix>=max)
{
     info();
     return 1;
}
function(argv[1],argv[2],argv[3],mix,max,size);
return 1;
}

int atoi(char s[])
{int i,n;
n = 0;
for(i = 0; s[i]>='0'&&s[i]<='9';++i)
    n= 10*n + (s[i] - '0');
return n;
}


int function(char Tbs_name[50],char Route_data_name[80],char Other_name[50],int Mix,int Max,int Size)
{
     int i=0;
     //start--

     printf("alter tablespace %s\n",Tbs_name);
     printf("add datafile\n");
     i=Mix;
     for (;i<Max;i++)
     {
          printf("'%s%d%s' ", Route_data_name,i,Other_name);
          printf("size %dm autoextend off,\n",Size);
     }
    
     printf("'%s%d%s' ", Route_data_name,i,Other_name);
     printf("size %dm autoextend off;\n",Size);
     //end

     printf("\n\n");
     return 1;
}
void info()
{
     //This is a Example

     printf("---------------------------------------------------------------------------\n\n");

     printf(" Format:\n");
     printf(" function(Tbs_name,Route_data_name,Other_name,Mix,Max,Size);\n\n");
     printf(" alter tablespace [Tbs_name]\n" );
     printf(" add datafile\n");
    printf(" '[Route_dataname] [mix] [max] [other_name]' size [size]m autoextend off;\n\n\n");

     printf(" This is a example.\n");
     printf(" alter tablespace tbs_name\n");
     printf(" add datafile\n");
     printf(" '/u01/data_01.dbf' size 1024m autoextend off,\n");
     printf(" '/u01/data_02.dbf' size 1024m autoextend off;\n\n");
     printf("---------------------------------------------------------------------------\n\n\n");

     printf("How to use!\n");
     printf("APP.exe tbs_name Route_dataname Other_name Mix Max Size \n\n");
     printf("---------------------------------------------------------------------------\n\n\n");
}
/*-------------------------------------version_2----------------------------------------------------*/




int main_version_2()
{
     //some default value

     int size=10;
     int mix=1;
     int max=2;
     int i=0;
     char tbs_name[50];
     char Route_dataname[50];
     char other_name[50];

     while(1)
     {
          info();
          //tbs_name

          printf("please input tbs_name:\n");
          scanf("%s",tbs_name);
          printf("The Tbs_name is %s\n\n",tbs_name);

          //data_name

          printf("please input Route_dataname:\n");
          scanf("%s",Route_dataname);
          printf("The Route_dataname is %s\n\n",tbs_name);

          //input other_nmae

          printf("please input other_name:\n");
          scanf("%s",other_name);
          printf("The Route_dataname is %s\n\n",other_name);

          //input min,max ,size

          printf("please input min,max and size value:\n");
          scanf("%d %d %d",&mix,&max,&size);
          printf("mix=%d,max=%d,size=%d\n\n",mix,max,size);

          if (mix>=max)
               return 0;
          //then do


          //start--

          printf("alter tablespace %s\n",tbs_name);
          printf("add datafile\n");
          i=mix;
          for (;i<max;i++)
          {
               printf("'%s%d%s' ", Route_dataname,i,other_name);
               printf("size %dm autoextend off,\n",size);
          }
         
          printf("'%s%d%s' ", Route_dataname,i,other_name);
          printf("size %dm autoextend off;\n",size);
         
          //end

          printf("\n\n");
     }
     return 1;
    
}

void info_2()
{
     //This is a Example

     printf("---------------------------------------------------------------------------\n\n");

     printf(" Format:\n");
     printf(" function(Tbs_name,Route_data_name,Other_name,Mix,Max,Size);\n\n");
     printf(" alter tablespace [Tbs_name]\n" );
     printf(" add datafile\n");
     printf(" '[Route_dataname] [mix] [max] [other_name]' size [size]m autoextend off;\n\n\n");

     printf(" This is a example.\n");
     printf(" alter tablespace tbs_name\n");
     printf(" add datafile\n");
     printf(" '/u01/data_01.dbf' size 1024m autoextend off,\n");
     printf(" '/u01/data_02.dbf' size 1024m autoextend off;\n\n");
     printf("---------------------------------------------------------------------------\n\n\n");

}




After run


可执行程序:down

C:\>cpp1.exe data /oradata/data01_ .dbf 2 30 2048
alter tablespace data
add datafile
'/oradata/data01_2.dbf' size 2048m autoextend off,
'/oradata/data01_3.dbf' size 2048m autoextend off,
'/oradata/data01_4.dbf' size 2048m autoextend off,
'/oradata/data01_5.dbf' size 2048m autoextend off,
'/oradata/data01_6.dbf' size 2048m autoextend off,
'/oradata/data01_7.dbf' size 2048m autoextend off,
'/oradata/data01_8.dbf' size 2048m autoextend off,
'/oradata/data01_9.dbf' size 2048m autoextend off,
'/oradata/data01_10.dbf' size 2048m autoextend off,
'/oradata/data01_11.dbf' size 2048m autoextend off,
'/oradata/data01_12.dbf' size 2048m autoextend off,
'/oradata/data01_13.dbf' size 2048m autoextend off,
'/oradata/data01_14.dbf' size 2048m autoextend off,
'/oradata/data01_15.dbf' size 2048m autoextend off,
'/oradata/data01_16.dbf' size 2048m autoextend off,
'/oradata/data01_17.dbf' size 2048m autoextend off,
'/oradata/data01_18.dbf' size 2048m autoextend off,
'/oradata/data01_19.dbf' size 2048m autoextend off,
'/oradata/data01_20.dbf' size 2048m autoextend off,
'/oradata/data01_21.dbf' size 2048m autoextend off,
'/oradata/data01_22.dbf' size 2048m autoextend off,
'/oradata/data01_23.dbf' size 2048m autoextend off,
'/oradata/data01_24.dbf' size 2048m autoextend off,
'/oradata/data01_25.dbf' size 2048m autoextend off,
'/oradata/data01_26.dbf' size 2048m autoextend off,
'/oradata/data01_27.dbf' size 2048m autoextend off,
'/oradata/data01_28.dbf' size 2048m autoextend off,
'/oradata/data01_29.dbf' size 2048m autoextend off,
'/oradata/data01_30.dbf' size 2048m autoextend off;

C:\>


感谢师同学提供了C#版本


阅读(724) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~