The data table name is changed (there is a rule of the same prefix), the system must modify the SQL statement

Source: Internet
Author: User
The name of the data table is changed (there is a regular number of the same prefix), the system must modify the SQL statement?
The SQL of the original system is as follows:
SELECT * from ' table ';
Today after the online, only to know:
For other reasons (not mentioned here).
All data tables must be renamed, to unify all the data tables, plus a prefix, is to add a "nbx_table"

What should I do?
First, do you want to change the system again? It's too much trouble, is it?
Second, how can you prevent it from happening next time?

Third, some CMS this write has what benefit:
$this->flinfos = $this->dsql->getone ("select * from ' #@__freelist ' WHERE aid= ' $fid '");

Share to:


------Solution--------------------
Some open source projects (CMS, BLOG, Wiki, framework ...) The reason for adding a prefix to the data table is:
Prevent conflicts with other application systems!
The rented space cannot create the database on its own, and when you place two or more items in the space, the table name is very prone to conflict.
------Solution--------------------
First, do you want to change the system again? It's too much trouble, is it?
This depends on how you access the database, such as Hibernate and mybatis do not need to modify the source code, directly to modify the mapping file can be.
If you are using JDBC in the source code to write dead SQL statement, this no way, can only pit the pit times to modify the source of SQL statements.

Second, how can you prevent it from happening next time?
use database persistence frameworks such as MyBatis and hibernate as much as possible.

Third, what is the benefit of some CMS writing: "Select * from ' #@__freelist ' WHERE aid= ' $fid '"
look at this SQL, inside #@__freelist and so on there is a flag, this is actually the last generation of SQL statements to be replaced with the specified variables in the configuration file, just can solve your problem.
  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.