One of the main poblems related to work with SQL is : exporting and importing .txt files to SQL.
I see myself too many websites and books for finding a simple command for this purpose , but most of them proposing tools or very difficult commands.
Myself , i am using the following simple command .
1- make a database : create database name_db ;
mysql> create database my_exper;
Enter in your database : Use my_exper ;
2- make a table with your favorite number of columns: create table exper ( U_Id varchar(18), Reg_No varchar(8) , Mob_No int , age int);
3- Import data from .txt files on your table in MYSQL : [ in my .txt file fields separated by "," ]
load data local infile "d:/myfile/m.txt" into table exper fields terminated by "," ;
some time no neccessary write local word on this command.
4- show tables from my_exper ;
5- show structure of your table : describe exper ;
6- show all rows in your table : select * from exper ;
7- Exporting (saving ) MySQL data in .txt file :
select * into outfile "D:/my_results/mr.txt" fields terminated by "," from exper where age>40 ;
I will be happy if share with me your new ideas.
Best wishes
I see myself too many websites and books for finding a simple command for this purpose , but most of them proposing tools or very difficult commands.
Myself , i am using the following simple command .
1- make a database : create database name_db ;
mysql> create database my_exper;
Enter in your database : Use my_exper ;
2- make a table with your favorite number of columns: create table exper ( U_Id varchar(18), Reg_No varchar(8) , Mob_No int , age int);
3- Import data from .txt files on your table in MYSQL : [ in my .txt file fields separated by "," ]
load data local infile "d:/myfile/m.txt" into table exper fields terminated by "," ;
some time no neccessary write local word on this command.
4- show tables from my_exper ;
5- show structure of your table : describe exper ;
6- show all rows in your table : select * from exper ;
7- Exporting (saving ) MySQL data in .txt file :
select * into outfile "D:/my_results/mr.txt" fields terminated by "," from exper where age>40 ;
I will be happy if share with me your new ideas.
Best wishes
No comments:
Post a Comment