[MDEV-7099] CREATE DATABASE xxxx LIKE yyyy Created: 2014-11-13  Updated: 2014-11-13

Status: Open
Project: MariaDB Server
Component/s: None
Fix Version/s: None

Type: Task Priority: Minor
Reporter: roberto spadim Assignee: Unassigned
Resolution: Unresolved Votes: 0
Labels: None


 Description   

Hi guys
I'm doing something that i do many times... but now i asked my self... why i'm doing this?! what i'm doing???

mysqldump some_database (without data) > sql.file
mysql sql.file to some new database...

instead of this, why shouldn't i execute something like:

CREATE DATABASE {new_database} [LIKE/CLONE] {old_database}

this will do something like ....

[LIKE]:
 
SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA="{old_database}";
CREATE TABLE {new_database}.{TABLE_NAME} LIKE {old_database}.{TABLE_NAME}
 
[CLONE]:
 
SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA="{old_database}";
CREATE TABLE {new_database}.{TABLE_NAME} LIKE {old_database}.{TABLE_NAME};
INSERT INTO {new_database}.{TABLE_NAME} SELECT * FROM {old_database}.{TABLE_NAME};

this save me from using shell (mysqldump/mysql) or heidisql or any other problem of dump, filesystem (saving the sql file with a nice user privilege chmod 777 , and after a rm file)
i think it's "easy" (must check what to do with foreign key and locks), i didn't checked how to create table like execute, but i think i could take a look, with a bit of time


Generated at Thu Feb 08 07:16:59 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.