在Oracle的11g版本中提供了统计数据自动收集的功能。在部署安装11g Oracle软件过程中,其中有一个步骤便是提示是否启用这个功能(
数据库报错
GATHER_STATS_JOB encountered errors. Check the trace file.
Errors in file /opt/Oracle/diag/rdbms/dbserver1/dbserver1/trace/dbserver1_j003_10544.trc:
ORA-20011: Approximate NDV failed: ORA-01476: divisor is equal to zero
环境
ORACLE 11G R2
RedHat 5.3 FOR 64 BIT
解决
网上给出的结论是BUG。
Bug No: 6040840
Filed 09-MAY-2007 Updated 10-MAY-2007
Product Oracle Server - Enterprise Edition Product Version 9.2.0.8
Platform. AIX5L Based Systems (64-bit) Platform. Version No Data
Database Version 9.2.0.8 Affects Platforms Generic
Severity Severe Loss of Service Status Duplicate Bug. To Filer
Base Bug 5645718 Fixed in Product Version No Data
Problem statement:
DBMS_STATS.GATHER_TABLE_STATS FAILS WITH ORA-1476.
WORKAROUND: ----------- n/a . RELATED BUGS: ------------- Bug#5645718.
不过我的数据库版本是11G,,应该不是这个BUG。
检查日志发现:
*** 2012-09-29 06:00:16.870
GATHER_STATS_JOB: GATHER_TABLE_STATS('"MIS"','"T_SALES_ORDER_ITEM"','""', ...)
ORA-20011: Approximate NDV failed: ORA-01476: divisor is equal to zero
检查T_SALES_ORDER_ITEM表发现该表select的时候也报错:
ORA-01476: divisor is equal to zero
查看表结构:
CREATE TABLE T_SALES_ORDER_ITEM
(
ID NUMBER(18) NOT NULL,
......
PREPAY_RATE NUMBER GENERATED ALWAYS AS (ROUND(TO_NUMBER(TO_CHAR("PREPAYMONEY"))*100/("PRICE"*"QUANTITY"),2))
......
最后 select price,quantity from T_SALES_ORDER_ITEM发现price有等于0的值!!!问题并不难解决,发现问题才是至关重要的。
修改PREPAY_RATE列,添加decode判断函数:
PREPAY_RATE NUMBER GENERATED ALWAYS AS (DECODE("PRICE",0,0,ROUND(TO_NUMBER(TO_CHAR("PREPAYMONEY"))*100/("PRICE"*"QUANTITY"),2)))

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters


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

SublimeText3 English version
Recommended: Win version, supports code prompts!

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

Zend Studio 13.0.1
Powerful PHP integrated development environment

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