Details
-
Type:
Task
-
Status: Open
-
Priority:
Minor
-
Resolution: Unresolved
-
Fix Version/s: None
-
Component/s: None
-
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
Gliffy Diagrams
Attachments
Activity
- All
- Comments
- Work Log
- History
- Activity
- Transitions