SQL Server Table and Column Alias for legacy applications

妖精的绣舞 提交于 2019-12-11 15:46:40

问题


Having just started working for a new client I have noticed that their database schema could do with a serious overhaul. I've made some suggestions (naming conventions mainly) which would be acceptable for the new suite of applications we are developing going forward, however the system would also have to support the lagacy names used (i.e. 400 or so externally hosted web applications).

Is there any way I could do the following:

  • Change the naming of tables and columns for use in the new application.
  • Create a permanenet table alias or similar to allow the lagacy code to remain unchaged?

Bit of a long shot.......


回答1:


What people do usually when refactoring is rename the table, create view with the old table name and structure and then make changes to the renamed table.

For instance if you renamed a column from person_id to personid (to enforce a consistent style) the view might reference personid but name it person_id so old code doesn't break.

If you are going to refactor a database and keep old code running, I highly recommend reading http://www.amazon.com/Refactoring-Databases-Evolutionary-Database-Design/dp/0321293533/ref=sr_1_1?ie=UTF8&s=books&qid=1254840934&sr=8-1




回答2:


you could rename the actual tables and columns names, then and write a bunch of views to support the old names. I'd not risk breaking or impacting the performance of 400 web sites, though. I think you'll just have to slog through. Draw some good table diagrams (so you can learn the names) and start going on the project.




回答3:


One way is to create updatable views. But with all its restrictions.



来源:https://stackoverflow.com/questions/1526068/sql-server-table-and-column-alias-for-legacy-applications

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!