Oracle数据库表设计时的注意事项
表是Oracle数据库中最基本的对象之一。万丈高楼从平地起,这个基础对象对于数据库来说,非常重要。因为其设计是否合理,直接
表是Oracle数据库中最基本的对象之一。万丈高楼从平地起,这个基础对象对于数据库来说,非常重要。因为其设计是否合理,直接跟数据库的性能相关。从Oracle数据库菜鸟到数据库专家这个过程中,在表设计与管理上,或多或少,会犯一些错误。笔者今天就谈谈自己在这方面的经验与教训,或许能够给大家一些警示作用。
经验一:在设计大型数据库时,把允许NULL的列放在表的后面。
在数据库表设计过程中,有些字段要求必须为非空,如表的关键字,单据编号字段等等。在数据库表创建的时候,往往需要把这些字段设置为非空。如此的话,就可以强制用户输入数据,以增强数据的一致性。
同时,在一张表中,也会有不少的字段,如员工信息表中,员工爱好、注释等字段,就可能允许为空。利用数据库专业术语来说,这些没有内容的字段就是“NULL”字段。
在数据库表设计的时候,对于这种类型的空字段要特别的留意。一方面,这个NULL字段,不是说其里面存储的是空格。若利用“’’”这个符号去查询空字段的记录的话,往往查不到我们想要的结果。因为在数据库存储的时候,若字段为NULL,则这个值根本没有存储。另一方面,正因为上面这种特性,所以,在表设计的时候,最好把允许NULL的字段放在表的末尾,当数据库比较大或者空字段比较多的话,则可以大大的减少数据库的存储空间。
另外,在数据库创建表的时候,是按照列建立的时间来排序的。所以,当某个列建立好之后,除非重新删除再建立,否则无法调整列的顺序。这就要求数据库管理员在创建表之前,就要对列、以及是否为空有一个明确的定义。只有如此,才能够合理安排列的顺序。
经验二:养成勤于写注释的习惯。
判断一个人是否是数据库专家,,从一个“注释”的小习惯中就可以 看得出来。若一个人在数据库开发的时候,勤与写注释,如在建立表或者字段的时候,能够利用comment命令对表与字段进行注释,则可以从一定程度上判断他是这方面的行家。相反,若其开发的数据库,注释没有多少,则基本可以判断,他是一个刚入门的菜鸟。或者说,其没有参加过大型数据库的设计。
这主要是因为,在数据库开发过程中,往往不是一个人可以完成的。如在开发一个ERP数据库的时候,可能有些人专门负责开发基础表,而有些人负责维护视图,等等。大家都是分工合作。同时,在前台也有程序员需要调用后台的数据库表与字段。所以,中大型的数据库与应用系统往往是大家协作的结果。
为此,为了提高表与字段的可读性,一个数据库管理人员开发的表格,大家都可以看的懂,就需要给表与字段设置比较详尽的注释。在Oracle数据库中,为了给其他伙伴提供有意义的帮助信息,就可以利用Comment命令来描述表、字段的作用以及一些引用的注意事项。这个小小的命令,可以大大提高表与字段的可读性,提高数据库与程序开发团队的协作性。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics











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.

In Oracle, the FOR LOOP loop can create cursors dynamically. The steps are: 1. Define the cursor type; 2. Create the loop; 3. Create the cursor dynamically; 4. Execute the cursor; 5. Close the cursor. Example: A cursor can be created cycle-by-circuit to display the names and salaries of the top 10 employees.

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.

Building a Hadoop Distributed File System (HDFS) on a CentOS system requires multiple steps. This article provides a brief configuration guide. 1. Prepare to install JDK in the early stage: Install JavaDevelopmentKit (JDK) on all nodes, and the version must be compatible with Hadoop. The installation package can be downloaded from the Oracle official website. Environment variable configuration: Edit /etc/profile file, set Java and Hadoop environment variables, so that the system can find the installation path of JDK and Hadoop. 2. Security configuration: SSH password-free login to generate SSH key: Use the ssh-keygen command on each node

When Oracle log files are full, the following solutions can be adopted: 1) Clean old log files; 2) Increase the log file size; 3) Increase the log file group; 4) Set up automatic log management; 5) Reinitialize the database. Before implementing any solution, it is recommended to back up the database to prevent data loss.

Oracle is not only a database company, but also a leader in cloud computing and ERP systems. 1. Oracle provides comprehensive solutions from database to cloud services and ERP systems. 2. OracleCloud challenges AWS and Azure, providing IaaS, PaaS and SaaS services. 3. Oracle's ERP systems such as E-BusinessSuite and FusionApplications help enterprises optimize operations.

Oracle views can be exported through the EXP utility: Log in to the Oracle database. Start the EXP utility, specifying the view name and export directory. Enter export parameters, including target mode, file format, and tablespace. Start exporting. Verify the export using the impdp utility.

MySQL is suitable for web applications and content management systems and is popular for its open source, high performance and ease of use. 1) Compared with PostgreSQL, MySQL performs better in simple queries and high concurrent read operations. 2) Compared with Oracle, MySQL is more popular among small and medium-sized enterprises because of its open source and low cost. 3) Compared with Microsoft SQL Server, MySQL is more suitable for cross-platform applications. 4) Unlike MongoDB, MySQL is more suitable for structured data and transaction processing.
