When the data table name is changed (a regular prefix is added), must the system modify the SQL statement?

Source: Internet
Author: User
When the data table name is changed (a regular prefix is added), must the system modify the SQL statement? The SQL format of the original system is as follows:
Select * from 'table ';
After going online today, you will know:
For other reasons (not mentioned here ).
All data tables must be renamed and all data tables must be prefixed with "nbx_table"

What should I do?
First, should I change the system again? Too much trouble, right?
Second, how can we prevent this from happening next time?

Third, what are the advantages of cms writing like this:
$ This-> FLInfos = $ this-> dsql-> GetOne ("SELECT * FROM '#@__ freelist 'Where aid =' $ fid '");


Reply to discussion (solution)

Some open-source projects (CMS, BLOG, Wiki, framework...) add a prefix to the data table because:
Prevent conflicts with other application systems!
No databases can be created for the rented space. when two or more projects are put in the space, the table names are prone to conflicts.

First, should I change the system again? Too much trouble, right?
This depends on how you access the database. for example, you can directly modify the ing file without modifying the source code of Hibernate and MyBatis.
If you use JDBC to write SQL statements in the source code, there is no way to modify the SQL statements in the source code.

Second, how can we prevent this from happening next time?
Try to use database persistence layer frameworks such as MyBatis and Hibernate.

Third, what are the advantages of cms writing like this: "SELECT * FROM '# @__ freelist 'Where aid =' $ fid '"
Take a closer look at this SQL statement. there is a mark in it, such as #__ freelist, which is replaced with the variable specified in the configuration file when the SQL statement is generated, this can solve your problem.

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.