Clone data between tables in SQL

Right now, will find out about the cloning of information between two unique tables in SQL.

A Table can hold a great deal of information which is significant at times. This information can be required by another table or we can likewise need an absolutely new table.

Presently suppose you need to have another table with similar records, in that circumstance cloning the whole information from a table to another table may be valuable.

There are different circumstances where you need to have a file of the information of a table at that point cloning the information from a table into another table and afterwards erasing the information from that table will be extremely helpful.

Cloning from a table is exceptionally straightforward and simple. Likewise, you can include extra fields which could be useful in the event that you need to make another table which will deal with the information.

To clone information from a table we should simply to make an additional inquiry which will take the information from the select question. The information ought to be serialized and good. You can accomplish something like this:

INSERT INTO A( id, name ) select id, name from B 

Sham table:

Clone data between tables in SQL

Syntax 1:

CREATE TABLE 'includehelp'.'employee' (
  'id' INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  'name' VARCHAR(45) NOT NULL,
  'age' INTEGER UNSIGNED NOT NULL,
  'address' VARCHAR(45) NOT NULL,
  'salary' INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY ('id')
)
ENGINE = InnoDB;

Syntax 2:

CREATE TABLE 'includehelp'.'employee' (
  'id' INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
  'name' VARCHAR(45) NOT NULL,
  'age' INTEGER UNSIGNED NOT NULL,
  'address' VARCHAR(45) NOT NULL,
  'salary' INTEGER UNSIGNED NOT NULL,
  PRIMARY KEY ('id')
)
ENGINE = InnoDB;

Example 1:

INSERT INTO CLONE_EMPLOYEE (id,name,age,address,salary)
SELECT id,name,age,address,salary FROM EMPLOYEE;
Clone data between tables in SQL

Example 2:

SELECT * FROM 'includehelp'.'clone_employee'
Clone data between tables in SQL

Leave a Comment

error: Alert: Content is protected!!