找回密碼
 註冊
搜索
查看: 3085|回復: 0

[MySQL] 修改Table prefix

[複製鏈接]
發表於 2018-8-23 09:39:45 | 顯示全部樓層 |閱讀模式
[mw_shl_code=sql,true]SET @database   = "database_name";
SET @old_prefix = "old_prefix_";
SET @new_prefix = "new_prefix_";

SELECT
    concat(
        "RENAME TABLE ",
        TABLE_NAME,
        " TO ",
        replace(TABLE_NAME, @old_prefix, @new_prefix),
        ';'
    ) AS "SQL"
FROM information_schema.TABLES WHERE TABLE_SCHEMA = @database;[/mw_shl_code]
Reference: https://richjenks.com/change-mysql-database-table-prefix/
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

Archiver|手機版|彩色筆小沛的知識庫

GMT+8, 2024-12-22 09:19 , Processed in 0.019169 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

快速回復 返回頂部 返回列表