当前位置:学学看123知识中心电脑教学数据库教程用gcc批量建mysql库表» 正文

用gcc批量建mysql库表

[06-11 18:14:58]   来源:http://www.xxk123.com  数据库教程   阅读:8136

导读: 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",

用gcc批量建mysql库表,标签:sql数据库教程,access数据库教程,http://www.xxk123.com


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("|\tnewtech@sina.com |\n");
printf("|\tOICQ:13721218 |\n");
printf("|\t 1/13/2001 |\n");
printf("----------------------------------\n");
}

file 2
table.h
char *table_file[]={

[1] [2]  下一页


Tag:数据库教程sql数据库教程,access数据库教程电脑教学 - 数据库教程
《用gcc批量建mysql库表》相关文章

Copyright 学学看123 All Right Reserved.

1 2 3 4 5 6 7 8 9 10