程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> MYSQL數據庫 >> MySQL綜合教程 >> 用gcc批量建mysql庫表

用gcc批量建mysql庫表

編輯:MySQL綜合教程

file 1

my.c
//--------------------------------------------------------
// MySQL Database Create 1/13/2001. Netkiller Chen
//--------------------------------------------------------
#include
#include
main()
{
char host[16]; //mysql host address.
char sid[15]; //root user name.
char pwd[15]; //root password.

/* char *table_file[]={
"gsxx",
"bcxx",
"fgxx",
"hmbxx",
"ltxx",
NULL
};*/
//char *mysql;
char mydatabase[256];
char mysqltable[256];
int i;
int max_table_num;
int db,status;
i=0;
max_table_num=4; //max_table_num

system("clear");
showme();printf("\n");

printf("MySQL host:");scanf("%s",host);
printf("Root user:");scanf("%s",sid);
printf("Password:");scanf("%s",pwd);
printf("Loading........\n\n");
while(table_file[i]){
sprintf(mydatabase,"echo \"create database %s\"|mysql -h%s -u%s -p%s",table_file[i],host,sid,pwd);
sprintf(mysqltable,"mysql -h%s -u%s -p%s %s<%s.sql",host,sid,pwd,table_file[i],table_file[i]);
db=system(mydatabase);
status=system(mysqltable);
// printf("%s\n%s",mydatabase,mysqltable);
printf(table_file[i]);
//printf("%d",status);
if(db==0 && status==0){
printf("\t\t\tInstall [ OK ]\n");
}else{
printf("\t\t\tInstall [ :( ]\n");
}
i++;
}
address();
}

//------------------- Function ------------------
showme()
{
printf("-------------------------------------------------------------------\n");
printf("\tI am Netkiller Chen.\n");
printf("\tI am a programmer and system&net manager.\n");
printf("\tI am glad to be friend with you!\n");
printf("-------------------------------------------------------------------\n");
}
address()
{
printf("\n----------------------------------\n");
printf("|\[email protected] |\n");
printf("|\tOICQ:13721218 |\n");
printf("|\t 1/13/2001 |\n");
printf("----------------------------------\n");
}

file 2
table.h
char *table_file[]={
"alxx",
"bcxx",
"fycx",
"fyxwxx",
"fyzxxx",
"hwzx",
"lhzxxx",
"xxdexx",
"xxdsxx",
"xxfgxx",
"xxglxx",
"xxgsxx",
"xxhmbxx",
"xxhtxx",
"xxjbxx",
"xxltxx",
"xxzwxx",
"xxzx",
NULL
};
些程序可以方便建表。。。有什麼不明白與我聯系。
程序隨算不上什麼。。。。。但也解決了一些批量建表的問提。
這個程序可以做為gcc剛入門愛好的參考,因為這個程序象hello world一樣間簡單。而且很全包括了指針,數組,文件包含,NULL

用戶方法兩個文件置於。/root/mygcc/下,將預建庫mysql語句文件,文件名命名為xxxx.sql同上然後
#gcc my.c -o my
#my
即可。。。不用我在說了吧?


  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved