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

Blueprint for self-improvement

To learn faster: Make the process fun To understand yourself : Write To understand the world better : Read To build deeper connection : Lis...