Friday, May 18, 2018

How do you insert old table record to new table?

Problem statement: How do you insert data of one table to other table for back up purpose?

Syntax:
INSERT new_table SELECT * FROM old_table;

e.g.

id | name | salary
01  ram      2000
02  rani      3000             ==> old_emp [old_table]
03  lata       1500
04  mary    1700


INSERT new_emp SELECT * FROM old_emp;

id | name | salary
01  ram      2000
02  rani      3000             ==> new_emp [new_table] 
03  lata       1500
04  mary    1700


No comments:

Post a Comment

How to run standalone mock server on local laptop

 Please download the standalone wiremock server from Direct download section at the bottom of the page.  Download and installation Feel fre...