重命名数据库中的所有表 [英] Rename all tables in database

查看:33
本文介绍了重命名数据库中的所有表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个数据库,其中所有表都以一组相同的字符为前缀.这样做是因为有一次他们在一个共享数据库中,该数据库是为具有数百个其他表的宠物项目设置的.应用程序以及数据库现在已准备好离开该阶段并准备好独立出来.我想删除每个表的前缀.有没有比右键单击并单独重命名每个表更简单的方法?

I have a database where all of the tables are prefixed with a set of the same characters. This was done because at one time they were in a shared database set up for pet projects with hundreds of other tables. The application, and thus the database, is now ready to be moved out of that phase and ready to be out on it's own. I would like to remove the prefix for each of the tables. Is there an easier way to do this rather than right-clicking and renaming each table individually?

推荐答案

您可以执行一些操作,例如编写整个数据库的脚本并对脚本进行字符串替换,然后在新数据库上运行它,然后导入数据.这当然取决于您可以匹配要替换的字符串的程度.您可能也必须在您的应用程序中进行相应的更改.你总是可以在测试数据库上尝试这样的事情,看看它是否有效.

You could do something like script the whole database and do string replacement on the script, run it on a new database, and then import the data. This of course depends on how well you can match the string to be replaced. You might have to make corresponding changes in your application too. You could always try something like this on a test database to see if it would work.

也看看这个 - 大量重命名表和存储过程

一种方法有一定成本,另一种方法与我的建议相似.

One method has some cost and the other is similar to my suggestion.

这篇关于重命名数据库中的所有表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆