Home Sql Backup selected records into txt file



Backup selected records into txt file
Posted on: December 31, 2008 at 12:00 AM
Backup selected records into txt file is used to copies the selected records or rows from a table into text file.

Backup selected records into txt file

     

Backup selected records into txt file is used to copies the selected records or rows from a table into text file. Further, the text file is used as backup file, whenever there is loss of records or rows from table. This text file is used to recover the records in the database  

Understand with Example

The Tutorial illustrate a Example from Backup Selected records into txt file. To restore the selected backup records into txt file, we create a table 'Stu_Table'. The create table is used to create a table 'Stu_Table' with table attribute like field name and data type respectively.

Create Table Stu_Table

Create Table Stu_Table( Stu_Id int, Stu_Name varchar(15),Stu_Class());

Insert Data Into Stu_Table

The insert into add the records or rows to the table 'Stu_Table'.

insert into stu_table values(1, 'Komal',10);
insert into stu_table values(2, 'Ajay',10);
insert into stu_table values(3, 'Santosh',10);
insert into stu_table values(4, 'Rakesh',10);
insert into stu_table values(5, 'Bhau',10);
insert into stu_table values(1, 'aaa',11);
insert into stu_table values(2, 'bbb',11);
insert into stu_table values(3, 'ccc',11);
insert into stu_table values(4, 'ddd',11);
insert into stu_table values(5, 'eee',11);
insert into stu_table values(1, 'iii',12);
insert into stu_table values(2, 'jjj',12);
insert into stu_table values(3, 'kkk',12);
insert into stu_table values(4, 'lll',12);
insert into stu_table values(5, 'mmm',12);

Stu_Table

+--------+----------+-----------+
| Stu_Id | Stu_Name | Stu_Class |
+--------+----------+-----------+
| 1      | Komal    | 10        |
| 2      | Ajay     | 10        |
| 3      | Santosh  | 10        |
| 4      | Rakesh   | 10        |
| 5      | Bhau     | 10        |
| 1      | aaa      | 11        |
| 2      | bbb      | 11        |
| 3      | ccc      | 11        |
| 4      | ddd      | 11        |
| 5      | eee      | 11        |
| 1      | iii      | 12        |
| 2      | jjj      | 12        |
| 3      | kkk      | 12        |
| 4      | lll      | 12        |
| 5      | mmm      | 12        |
+--------+----------+-----------+

Backup query 

The Backup Query create a backup copy of records from table 'stu_table' where stu_class is equal to '11' into a text file name 'abc'.

select * into outfile 'c:/abc.txt' 
from stu_table where stu_class = 11;

Backup successful ....

Related Tags for Backup selected records into txt file:
cdatabasefiletabletextdataselectbackupsedintthistabrowtxttexrowsierecordcterecordstobaseselectedwsexteilbackusefrominasmntososesrecoveraseoverpiepilossintoackwhensatosskiscovercoprdsrtxtwheneverssrdthabablomo


More Tutorials from this section

Ask Questions?    Discuss: Backup selected records into txt file  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.