Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Sql SQL Backup Table

Related Tutorials


 
 

Share on Google+Share on Google+

SQL Backup Table

Advertisement
The Select Statement is used to create backup copies of tables.

SQL Backup Table

     

The Select Statement is used to create backup copies of tables.

Understand with Example

The Tutorial illustrate a example from SQL Backup Table. In this Example, we create a table 'Stu_Table'. The create table statement create a table 'Stu_Table'. 

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 exact back up copy of table 'stu_table'. The create table construct a table 'stu_table_backup' and copies the exact data of table 'stu_table'. The SELECT INTO statement is most often used to create backup copies of tables

create table stu_table_backup( select * from stu_table);

Stu_Table_Backup

+--------+----------+-----------+
| 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        |
+--------+----------+-----------+
Advertisement

If you enjoyed this post then why not add us on Google+? Add us to your Circles



Liked it!  Share this Tutorial


Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Posted on: December 20, 2008

Related Tutorials

Discuss: SQL Backup Table  

Post your Comment


Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
 
 
Comments:5
Sophara
November 30, 2011
Test

Comments
Shashank Shama
December 21, 2011
SQL BACKP TABLE

it should be "create table stu_table_backup as( select * from stu_table); "
shankar
March 20, 2012
wrong query

above query is wrong.. use create table stu_table_backup AS ( select * from stu_table);
Anil
November 4, 2012
Data backup

can we get all the constraints along with the data back up
Bella
July 9, 2013
SQL for BACKUP

how to create SQL statement that will backup records from multiple tables. then I will delete those records after couple of days from backup table
DMCA.com