Copy Table or a Particular Column’s data in another table SQL

Date Published: 26/07/2020 Published By: JaiSchool

We can copy the whole table or its specific columns we want to copy.

Create table and copy another table data

CREATE TABLE users AS SELECT * FROM admission;

Or

INSERT INTO admission(name,village,district,state,country) SELECT * FROM users;

But column count in both tables should match if you use all column selector ( * ). In the above example, the admission table contains five columns & the users table also contains five columns. The column name may be different in both tables.

Copy specific column data

INSERT INTO admission(name) SELECT name FROM users;

Publish A Comment

Leave a Reply

Your email address will not be published. Required fields are marked *