search
HomeDatabaseMysql Tutorial通过shell检查Oracle分区表中是否含有默认分区

在大数据量的系统中,分区表是很常见的,分区有多种类型,可以根据业务来选择自己需要的分区,不过为了数据的兼容性,需要考虑对于分

在大数据量的系统中,分区表是很常见的,分区有多种类型,可以根据业务来选择自己需要的分区,不过为了数据的兼容性,需要考虑对于分区表设定一个默认的表分区,如果数据在插入表分区的时候,,没有符合条件的分区,就会插入默认的表分区中。

这个可以根据自己的需要来设定,如果确实对数据有严格的要求,甚至可以要求不加入默认的分区。

以下的脚本会去"扫描"分区的信息,如果检测到没有默认的分区,就会生成对应的脚本。

可以根据自己的情况来决定是否需要加入分区。

sqlplus -s $1/$2@$SH_DB_SID  set head off
 set pages 100
 set linesize 200
 /* bad performance
 select name,Count(*)from user_part_key_columns where object_type='TABLE' and name in
 (
 select table_name from user_tables where partitioned='YES'
 minus
  (select distinct  table_name
 from user_tab_partitions where  partition_name like '%MAX%'
  )
 )
 group by name;
 */
 select 'alter table  '||table_name||' add partition  PMAXVALUE  values less than ('||
 decode(col_count, 1, 'MAXVALUE',
                                                          2,'MAXVALUE,MAXVALUE',
                                                          3,'MAXVALUE,MAXVALUE,MAXVALUE',
                                                          4,'MAXVALUE,MAXVALUE,MAXVALUE,MAXVALUE','partition out of range')||');'
    from
 (
 (
 select t1.table_name,count(t2.name) col_count from user_tables t1,user_part_key_columns t2
 where t1.partitioned='YES'
 and t1.table_name=t2.name
 and t2.object_type='TABLE'
 group by t1.table_name
 )
 minus
  (
  select  t2.name table_name,count(t2.name)col_count
 from user_tab_partitions t1,user_part_key_columns t2
 where  t1.partition_name like '%MAX%'
 and t1.table_name=t2.name
 and t2.object_type='TABLE'
 group by t2.name
  )
 )
 /

EOF
 exit

 简单运行一下,可以看到有一些分区表是灭有默认的分区的。可以根据自己的情况来定夺。

[ora11g@rac1 dbm_lite]$ ksh getmaxpar.sh system Oracle

alter table  LOGMNRC_GSBA add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNRC_GSII add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNRC_GTCS add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNRC_GTLO add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNRP_CTAS_PART_MAP add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_ATTRCOL$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_ATTRIBUTE$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_CCOL$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_CDEF$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_COL$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_COLTYPE$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_DICTIONARY$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_DICTSTATE$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_ENC$ add partition  PMAXVALUE  values less than (MAXVALUE);
 alter table  LOGMNR_ICOL$ add partition  PMAXVALUE  values less than (MAXVALUE);

浅谈Oracle分区表之范围分区

Oracle分区表迁移

Oracle分区表使用实例

Oracle分区表 (Partition Table) 的创建及管理

本文永久更新链接地址:

linux

Statement
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
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

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

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

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

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

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

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

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

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

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: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

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

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

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

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

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

See all articles

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 Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software