Table of Contents
回复讨论(解决方案)
Home Backend Development PHP Tutorial mysql中的表前缀应该丢进历史的垃圾堆。

mysql中的表前缀应该丢进历史的垃圾堆。

Jun 23, 2016 pm 01:49 PM
mysql prefix history

1、表前缀广泛使用,却毫无用处。在服务器几乎都快是不要钱的了,数据完全就是免费的。一个数据库中容纳2个数据库中有意义么?
2、给编程和维护,数据库维护带来极*烦。犹如马克思主义,毛XX思想一样。只有害处,毫无好处。

谁能给我一个必须用前缀的理由??

答案就不用大家给我了,我自己给。在99.99%的情况不需要。反正我是重来没有用到过。

我想调查一下,谁的项目中一定需要表前缀的?能介绍下么?天下海选,看是否真有人需要表前缀?

跟贴有分。


回复讨论(解决方案)

如果你的数据库支持多个多个数据库,那就没什么意义,如果只有一个,对于区分表,还是有帮助的。

购买空间的,只能创建一个数据库。加前缀就很有用了,楼主不能忽略这些用户。

购买空间的,只能创建一个数据库。加前缀就很有用了,楼主不能忽略这些用户。


正规100元一个空间,就带免费数据库,有必要一个数据库时塞2个数据库么?
多买一个空间啊。真正运行的程序,100元一年都出不起么?
本地开发当然是要多少个数据库就多少个数据库。

我见过和用过的项目至少20+以上吧。从来没有需要前缀的时候,但居然个个项目都有前缀。

防止某些不怀好意的高水平用户猜测?
开源CMS难免会有些漏洞吧,多个表前缀也许多一层防护?
用来实现某种功能?比如中文版/英文版?

楼主好像自己也开着有公司吧?
多买一个空间啊。真正运行的程序,100元一年都出不起么?这样的话你也能对你的客户说出来?
我就是要把一个 dede,一个 Discuz! 、一个 wordpress 放在一个空间里,以后还想加个 wiki 和问答系统。
难道您销售的系统不支持这样做吗?那么我何必花钱买你的系统,而不去用免费的开源系统呢?

很多设定本来都是不合理的。但按照有关部门的意思就是历史遗留原因。


比如计算机语言,五花八门。其实如果语言真的好,一种就足够了。

比如系统对图片、动画的支持差,则是因为当时开始做计算机的时候,工程师只考虑文字。只需要屏幕出现一些文字就行了。虽然后来图片算法出现了,动画算法出现了。但这些后来出现的,都是在原本不支持他们的硬软件环境下诞生的,于是文件变得很大,很难使用。

想要改变这些缺陷,必须全面重构底层,重新架构系统。但这些是不可能的了。所以将就着用吧。


mysql这个,其实和什么几个数据库没有关系。你也可以做表后缀,也可以做表中缀。只是一个命名规则而已,尊不遵守都行。


购买空间的,只能创建一个数据库。加前缀就很有用了,楼主不能忽略这些用户。


正规100元一个空间,就带免费数据库,有必要一个数据库时塞2个数据库么?
多买一个空间啊。真正运行的程序,100元一年都出不起么?
本地开发当然是要多少个数据库就多少个数据库。

但一?空?已??用,?何要因?根?模?分???而?多一?空?呢?100元也是?啊,大哥。

楼主好像自己也开着有公司吧?
多买一个空间啊。真正运行的程序,100元一年都出不起么?这样的话你也能对你的客户说出来?
我就是要把一个 dede,一个 Discuz! 、一个 wordpress 放在一个空间里,以后还想加个 wiki 和问答系统。
难道您销售的系统不支持这样做吗?那么我何必花钱买你的系统,而不去用免费的开源系统呢?


节省的这100元,代码维护多花费的精力成本何止1000元以上?

我运营网站的目的并不是为了学习如何搭建一个网站
所以我不可能为了你的维护方便而掏钱买上多个空间,其实如果我有多个空间,那么你维护起来不也是很麻烦吗?
再说各个系统都是独立运行,互不干涉,何来的“多花费的精力”

我运营网站的目的并不是为了学习如何搭建一个网站
所以我不可能为了你的维护方便而掏钱买上多个空间,其实如果我有多个空间,那么你维护起来不也是很麻烦吗?
再说各个系统都是独立运行,互不干涉,何来的“多花费的精力”


表前缀会给编程带来麻烦,给代码维护多带来的精力何止1万元以上成本。
不用前缀,平均一个项目至少节省1万以上开发和维护成本。

我想知道你所说的麻烦、难维护到底体现在哪块呢?
而且如果都如 多买一个空间啊。真正运行的程序,100元一年都出不起么?  ,那么一个库需要多种前缀,就需要再多买几个空间么?
难道前缀仅仅是为了摆设?

我加前缀是为了一眼就能区分这些表是属于哪个功能模块,那我查找表的时候范围也就更小了,找到的时间也就更加少了,难道胡乱放一堆,一个一个找?当然,不同场景需要的程度也不一致,你用不到并不能说明没用。

就算不用前缀,多放几个库,来回切库维护成本就低了?

表前缀不会给编程带来麻烦,尤其是封装好的数据层更是小菜一碟
表前缀会是运行速度略微下降,因为需要有一次表名的组装
表前缀可以使程序通用化程度加强,不同应用间不再需要为防止表名相同而大伤脑筋
表前缀可以在程序开发期间轻松的更换测试数据
也可在维护时不影响系统的正常运行,只需单独指派一个 config 就切换到模拟数据上了
而不用表前缀时,你可能需要备份数据库,并提防测试数据暴露到网站上

当然,表前缀只是为工作方便而使用的一个技术手段而已。用不用是你自己的事情

既然你有 Java 经历,那么你也应该知道 Java 从 C++ 脱离出来的时候放弃了 C/C++ 的外部文件包含(#include)。以为只要规划好类,就不再需要引入外部文件了。但事情总是那么的不如意,第二年也只有再造一个 Import 来弥补了

表前缀不会给编程带来麻烦,尤其是封装好的数据层更是小菜一碟
表前缀会是运行速度略微下降,因为需要有一次表名的组装
表前缀可以使程序通用化程度加强,不同应用间不再需要为防止表名相同而大伤脑筋
表前缀可以在程序开发期间轻松的更换测试数据
也可在维护时不影响系统的正常运行,只需单独指派一个 config 就切换到模拟数据上了
而不用表前缀时,你可能需要备份数据库,并提防测试数据暴露到网站上

当然,表前缀只是为工作方便而使用的一个技术手段而已。用不用是你自己的事情

既然你有 Java 经历,那么你也应该知道 Java 从 C++ 脱离出来的时候放弃了 C/C++ 的外部文件包含(#include)。以为只要规划好类,就不再需要引入外部文件了。但事情总是那么的不如意,第二年也只有再造一个 Import 来弥补了



php几乎完全做到了不用手工引用外部文件。

我想知道你所说的麻烦、难维护到底体现在哪块呢?
而且如果都如 多买一个空间啊。真正运行的程序,100元一年都出不起么?  ,那么一个库需要多种前缀,就需要再多买几个空间么?
难道前缀仅仅是为了摆设?

我加前缀是为了一眼就能区分这些表是属于哪个功能模块,那我查找表的时候范围也就更小了,找到的时间也就更加少了,难道胡乱放一堆,一个一个找?当然,不同场景需要的程度也不一致,你用不到并不能说明没用。

就算不用前缀,多放几个库,来回切库维护成本就低了?


我认为前缀不好的原因,就在于快速找表。
前缀影响我阅读表名。
开始看前缀时,我以为前缀有何意义。最后发现,屁意义都没有。就是前缀而已。

能不能引入外部文件和要不要引入外部文件,是两个不同的范畴

前缀的存在就在于款速找表,相同前缀的肯定隶属于相同的应用
你可把前缀理解为分组(分类)标志

存在即意义。
前缀的存在就是为了快速区分不同表之间的意义。当然,如果没必要区分,也完全没必要用前缀了。
也许你觉得屁意义没有,给你工作带来无限的麻烦,成本大大提高了,完全可以摒弃。但熟不知,表前缀也许给其他人工作上带了许多便利。
在一个大型应用中,也许有许多相互关联、高耦合的关系表,但不隶属同一模块,也许前缀的意义就体现出来了。否则多库操作,难道表的关系也要升级到库的关系?反而不美~

还是那句话,存在即意义。

经过几个月思考和争论:结论如下。
1、楼上17楼是正解。xuyanlu
2、16楼回答不错。
 3、6楼你的回复在20年前也许正确。现在完全错误。

前缀做为分组用有存在的必要,但整个表都是前缀,完全就是病态。
在此完全木有考虑在互联网上整天做练习的xuzun这样的人。因为这样的整个中国找不到3个人吧?所以忽略。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

Solve database connection problem: a practical case of using minii/db library Solve database connection problem: a practical case of using minii/db library Apr 18, 2025 am 07:09 AM

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

Centos install mysql Centos install mysql Apr 14, 2025 pm 08:09 PM

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

See all articles