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: Simple Concepts for Easy Learning MySQL: Simple Concepts for Easy Learning Apr 10, 2025 am 09:29 AM

MySQL is an open source relational database management system. 1) Create database and tables: Use the CREATEDATABASE and CREATETABLE commands. 2) Basic operations: INSERT, UPDATE, DELETE and SELECT. 3) Advanced operations: JOIN, subquery and transaction processing. 4) Debugging skills: Check syntax, data type and permissions. 5) Optimization suggestions: Use indexes, avoid SELECT* and use transactions.

How to open phpmyadmin How to open phpmyadmin Apr 10, 2025 pm 10:51 PM

You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL: An Introduction to the World's Most Popular Database MySQL: An Introduction to the World's Most Popular Database Apr 12, 2025 am 12:18 AM

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

How to use single threaded redis How to use single threaded redis Apr 10, 2025 pm 07:12 PM

Redis uses a single threaded architecture to provide high performance, simplicity, and consistency. It utilizes I/O multiplexing, event loops, non-blocking I/O, and shared memory to improve concurrency, but with limitations of concurrency limitations, single point of failure, and unsuitable for write-intensive workloads.

Why Use MySQL? Benefits and Advantages Why Use MySQL? Benefits and Advantages Apr 12, 2025 am 12:17 AM

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

MySQL's Place: Databases and Programming MySQL's Place: Databases and Programming Apr 13, 2025 am 12:18 AM

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL and SQL: Essential Skills for Developers MySQL and SQL: Essential Skills for Developers Apr 10, 2025 am 09:30 AM

MySQL and SQL are essential skills for developers. 1.MySQL is an open source relational database management system, and SQL is the standard language used to manage and operate databases. 2.MySQL supports multiple storage engines through efficient data storage and retrieval functions, and SQL completes complex data operations through simple statements. 3. Examples of usage include basic queries and advanced queries, such as filtering and sorting by condition. 4. Common errors include syntax errors and performance issues, which can be optimized by checking SQL statements and using EXPLAIN commands. 5. Performance optimization techniques include using indexes, avoiding full table scanning, optimizing JOIN operations and improving code readability.

Monitor Redis Droplet with Redis Exporter Service Monitor Redis Droplet with Redis Exporter Service Apr 10, 2025 pm 01:36 PM

Effective monitoring of Redis databases is critical to maintaining optimal performance, identifying potential bottlenecks, and ensuring overall system reliability. Redis Exporter Service is a powerful utility designed to monitor Redis databases using Prometheus. This tutorial will guide you through the complete setup and configuration of Redis Exporter Service, ensuring you seamlessly build monitoring solutions. By studying this tutorial, you will achieve fully operational monitoring settings

See all articles