copy table mysql code example
Example 1: copy table oracle
CREATE TABLE New_Table_name AS SELECT * FROM Existing_table_Name;
Example 2: mysql copy table with new name
CREATE TABLE IF NOT EXISTS new_table LIKE existing_table;
INSERT new_table
SELECT * FROM existing_table;
Example 3: create table mysql
CREATE TABLE IF NOT EXISTS tasks (
task_id INT AUTO_INCREMENT PRIMARY KEY,
title VARCHAR(255) NOT NULL,
start_date DATE,
due_date DATE,
status TINYINT NOT NULL,
priority TINYINT NOT NULL,
description TEXT,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=INNODB;
Example 4: copy database mysql
mysqldump -u root -p db_caweb | mysql -u root -p root db_caweb_23012021;