您的位置: 翼速应用 > 业内知识 > 数据库 > 正文

在mysql中应该如何修改表前缀?


操作windows10、mysql8.0.22版本、Dell G3电脑时mysql如何修改表前缀


如何修改表前缀



使用sql语句修改mysql数据库表前缀名


首先我们想到的就是用sql查询语句来修改,这个方法也很方便,在运行 SQL 查询框中输入如下语名就可以了。


ALTER TABLE 原表名 RENAME TO 新表名;


如:


ALTER TABLE old_post RENAME TO new_post;


Sql查询语句有一个缺点,那就是一句SQL语句只能修改一张数据库的表名,如果你要精确修改某一张表,很好用。如果数据库表很多的话,比较麻烦。


但是我们可以通过一条语句一次性生成所有的sql语句:


select concat('alter table ',table_name,' rename to ',table_name) from information_schema.tables where table_name like'dmsck_%';


生成语句如下:


alter table dmsck_acategory rename to dmsck_acategory;

alter table dmsck_address rename to dmsck_address;

alter table dmsck_article rename to dmsck_article;

alter table dmsck_attrcategory rename to dmsck_attrcategory;

alter table dmsck_attribute rename to dmsck_attribute;

alter table dmsck_brand rename to dmsck_brand;

alter table dmsck_cart rename to dmsck_cart;

alter table dmsck_category_attr rename to dmsck_category_attr;

alter table dmsck_category_goods rename to dmsck_category_goods;

alter table dmsck_category_store rename to dmsck_category_store;

alter table dmsck_collect rename to dmsck_collect;

alter table dmsck_comment rename to dmsck_comment;

alter table dmsck_coupon rename to dmsck_coupon;

alter table dmsck_coupon_sn rename to dmsck_coupon_sn;

alter table dmsck_enterprise rename to dmsck_enterprise;

alter table dmsck_filmstrip rename to dmsck_filmstrip;

alter table dmsck_friend rename to dmsck_friend;

alter table dmsck_function rename to dmsck_function;

alter table dmsck_gattribute_rule rename to dmsck_gattribute_rule;

alter table dmsck_gcategory rename to dmsck_gcategory;

alter table dmsck_goods rename to dmsck_goods;

alter table dmsck_goods_attr rename to dmsck_goods_attr;

alter table dmsck_goods_bak rename to dmsck_goods_bak;

alter table dmsck_goods_down_log rename to dmsck_goods_down_log;

alter table dmsck_goods_image rename to dmsck_goods_image;

alter table dmsck_goods_old rename to dmsck_goods_old;

alter table dmsck_goods_qa rename to dmsck_goods_qa;

alter table dmsck_goods_spec rename to dmsck_goods_spec;

alter table dmsck_goods_statistics rename to dmsck_goods_statistics;

alter table dmsck_groupbuy rename to dmsck_groupbuy;

alter table dmsck_groupbuy_log rename to dmsck_groupbuy_log;

alter table dmsck_keyword rename to dmsck_keyword;

alter table dmsck_mail_queue rename to dmsck_mail_queue;

alter table dmsck_member rename to dmsck_member;

alter table dmsck_message rename to dmsck_message;

alter table dmsck_module rename to dmsck_module;


然后将其复制到一个文本文件中,将要修改的前缀统一修改(稍稍麻烦),然后再复制到mysql中执行sql语句就ok了。




以上就是在mysql中该如何修改表前缀的全部内容,想了解更多的话请关注翼速网络应用平台获取更多内容!


我来说两句

0 条评论

推荐阅读

  • 响应式布局CSS媒体查询设备像素比介绍

    构建响应式网站布局最常见的是流体网格,灵活调整大小的站点布局技术,确保用户在使用的幕上获得完整的体验。响应式设计如何展示富媒体图像,可以通过以下几种方法。

    admin
  • 提升网站的性能快速加载的实用技巧

    网站速度很重要,快速加载的网站会带来更好的用户体验、更高的转化率、更多的参与度,而且在搜索引擎排名中也扮演重要角色,做SEO,网站硬件是起跑线,如果输在了起跑线,又怎么跟同行竞争。有许多方法可提升网站的性能,有一些技巧可以避免踩坑。

    admin
  • 织梦CMS TAG页找不到标签和实现彩色标签解决方法

    织梦cms是我们常见的网站程序系统的一款,在TAG标签中常常遇到的问题也很多。当我们点击 tags.php 页的某个标签的时候,有时会提示:“系统无此标签,可 能已经移除!” 但是我们检查程序后台,以及前台显示页面。这个标签确实存在,如果解决这个问题那?

    admin
  • HTML关于fieldset标签主要的作用

    在前端开发html页面中常用的标签很多,今天为大家带来的是关于HTML中fieldset标签主要的作用说明,根据技术分析HTML

    admin

精选专题