-- structure and data
CREATE TABLE students_backup AS
SELECT * FROM students;
-- only the structure (empty table, with indexes)
CREATE TABLE students_empty LIKE students;
-- structure first, then copy the data
INSERT INTO students_empty SELECT * FROM students;
CREATE TABLE ... AS SELECT copies the columns and the data, but it does not copy the primary key, indexes and auto increment. CREATE TABLE ... LIKE copies the full structure, including indexes, but no data. Use WHERE in the SELECT to copy only some rows.
Learn more about the similar topics:
| Tutorials |
| No Content Found. |
| Exercises & Assignments |
| No Content Found. |
| Interview Questions & Answers |
| No Content Found. |