greenplum partition table

简介: greenplum 分区表,索引 greenplum 分区按照类型可以分为 #列表分表 create table gh_par_list( id1 integer, id2 varchar(10)) distribute...
greenplum 分区表,索引


greenplum 分区按照类型可以分为


#列表分表


create table gh_par_list(
id1 integer,
id2 varchar(10))
distributed by (id1)
partition by list(id2)
(
partition p1 values ('1','2') tablespace ts_gh,
partition p2 values ('3','0')
tablespace ts_gh,
default partition pd
tablespace ts_gh
);






#范围分区


create table gh_par_range
(id1 integer,
 id2 varchar(10),
 id3 date)
 distributed by (id1)
 partition by range(id3)
 (partition p1 start ('2011-01-01'::date) end ('2012-01-01'::date) tablespace ts_gh,
 partition p2 start('2020-01-01'::date) end ('2021-01-01'::date) tablespace ts_gh);
 
##简便分区


create table gh_par_range_every
(id1 integer,
 id2 varchar(10),
 id3 date)
 distributed by (id1)
partition by range(id3)
(partition p2011 start ('2011-01-01'::date) end ('2030-01-01'::date) every ('1 year'::interval) tablespace ts_gh);


#表和分区的联系




tutorial=> \d pg_partition;
    Table "pg_catalog.pg_partition"
    Column     |    Type    | Modifiers 
---------------+------------+-----------
 parrelid      | oid        | not null
 parkind       | "char"     | not null
 parlevel      | smallint   | not null
 paristemplate | boolean    | not null
 parnatts      | smallint   | not null
 paratts       | int2vector | not null
 parclass      | oidvector  | not null
Indexes:
    "pg_partition_oid_index" UNIQUE, btree (oid)
    "pg_partition_parrelid_index" btree (parrelid)
    "pg_partition_parrelid_parlevel_istemplate_index" btree (parrelid, parlevel, paristemplate)




tutorial=> 


**pg_partition中的parrelid关联pg_class的oid**








tutorial=> \d pg_partition_rule;
   Table "pg_catalog.pg_partition_rule"
      Column       |   Type   | Modifiers 
-------------------+----------+-----------
 paroid            | oid      | not null
 parchildrelid     | oid      | not null
 parparentrule     | oid      | not null
 parname           | name     | not null
 parisdefault      | boolean  | not null
 parruleord        | smallint | not null
 parrangestartincl | boolean  | not null
 parrangeendincl   | boolean  | not null
 parrangestart     | text     | 
 parrangeend       | text     | 
 parrangeevery     | text     | 
 parlistvalues     | text     | 
 parreloptions     | text[]   | 
 partemplatespace  | oid      | 
Indexes:
    "pg_partition_rule_oid_index" UNIQUE, btree (oid)
    "pg_partition_rule_parchildrelid_index" btree (parchildrelid)
    "pg_partition_rule_parchildrelid_parparentrule_parruleord_index" btree (parchildrelid, parp
arentrule, parruleord)
    "pg_partition_rule_paroid_parentrule_ruleord_index" btree (paroid, parparentrule, parruleor
d)




tutorial=> 




**pg_partition_rule中的paroid关联pg_partition的oid**




##创建视图直接查询
create view vw_partition as 
select pp.parrelid tableoid ,prl.parchildrelid,prl.parname as partitionname 
from pg_partition pp,pg_partition_rule prl
where pp.paristemplate=false and prl.paroid=pp.oid;


select * from vw_partition t where tableoid='public.gh_par_range'::regclass;






#分区操作


##增加


alter table gh_par_range 
add partition p3 start ('1991-01-01'::date) end ('1992-01-01'::date);


##删除




 alter table gh_par_range drop partition p3;


##清空


alter table gh_par_range truncate partition p3;
##分离


alter table gh_par_range
split partition p3
at ('1991-07-01'::date)
into (partition p4,partition p5);


##交换




2016-12-01

greenplum 支持对表进行分区

分区表

逻辑上的一个大表分割为物理上的几块


greenplum  来自于 postgresql


postgresql 创建分区表 步骤

1)创建主表,所有分区都从它继承

2)创建几个子表,每个都从主表上继承

3)为分区表增加约束,定义每个分区允许的键值

4)对于每个分区,在关键字字段上创建一个索引,以及其他想创建的索引。

5)定义一个规则或触发器,把对主表的修改重定向到合适的分区表


greenplum 来说,分区表的实现原理与上面介绍的一样

分区表目前支持范围分区和列表分区

范围分区


创建范围分区
tutorial=> create table gh_partition_range(id int,name varchar(32),dw_end_date date)
tutorial-> distributed by (id)
tutorial-> partition by range (dw_end_date)
tutorial-> (
tutorial(> partition p2015 start ('2015-01-01'::date) end ('2016-01-01'::date),
tutorial(> partition p2016 start ('2016-01-01'::date) end ('2017-01-01'::date)
tutorial(> );
NOTICE:  CREATE TABLE will create partition "gh_partition_range_1_prt_p2015" for table "gh_partitio
n_range"NOTICE:  CREATE TABLE will create partition "gh_partition_range_1_prt_p2016" for table "gh_partitio
n_range"CREATE TABLE

插入数据
tutorial=> insert into gh_partition_range values(1,23,'2015-01-01'::date);
INSERT 0 1
tutorial=> select * from gh_partition_range;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2015-01-01
(1 row)

tutorial=> insert into gh_partition_range values(1,23,'2016-01-01'::date);
INSERT 0 1

插入数值大于分区范围报错
tutorial=> insert into gh_partition_range values(1,23,'2018-01-01'::date);
ERROR:  no partition for partitioning key  (seg0 slave1:40000 pid=1875)


查询数据
tutorial=> select * from gh_partition_range;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2015-01-01
  1 | 23   | 2016-01-01
(2 rows)

查询分区数据
tutorial=> select * from gh_partition_range_1_prt_p2015;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2015-01-01
(1 row)
tutorial=> select * from gh_partition_range_1_prt_p2016;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2016-01-01
(1 row)

添加分区
tutorial=> alter table gh_partition_range add partition p2017 start ('2017-01-01'::date) end ('2018-01-01'::date);
NOTICE:  CREATE TABLE will create partition "gh_partition_range_1_prt_p2017" for table "gh_partitio
n_range"ALTER TABLE
tutorial=> insert into gh_partition_range values(1,23,'2017-01-01'::date);
INSERT 0 1
tutorial=>
tutorial=> select * from gh_partition_range_1_prt_p2017;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2017-01-01
(1 row)

删除分区
tutorial=> alter table gh_partition_range drop partition p2017;
ALTER TABLE
tutorial=>

清空分区
tutorial=> alter table gh_partition_range truncate partition p2015;
ALTER TABLE
tutorial=> select * from gh_partition_range;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2016-01-01
(1 row)


分离分区

tutorial=> alter table gh_partition_range split partition p2016  at (('2016-06-01'::date)) into (partition p2016s, partition p2016x);
NOTICE:  exchanged partition "p2016" of relation "gh_partition_range" with relation "pg_temp_85849"
NOTICE:  dropped partition "p2016" for relation "gh_partition_range"
NOTICE:  CREATE TABLE will create partition "gh_partition_range_1_prt_p2016s" for table "gh_partiti
on_range"NOTICE:  CREATE TABLE will create partition "gh_partition_range_1_prt_p2016x" for table "gh_partiti
on_range"ALTER TABLE
tutorial=> select * from gh_partition_range;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2016-01-01
  1 | 25   | 2016-01-01
  1 | 25   | 2016-02-01
  1 | 25   | 2016-06-01
  1 | 25   | 2016-07-01
(5 rows)

tutorial=> select * from gh_partition_range_1_prt_p2016s;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2016-01-01
  1 | 25   | 2016-01-01
  1 | 25   | 2016-02-01
(3 rows)

tutorial=> select * from gh_partition_range_1_prt_p2016x;
id | name | dw_end_date
----+------+-------------
  1 | 25   | 2016-06-01
  1 | 25   | 2016-07-01
(2 rows)


交换分区(表字段名称,顺序,类型,字段长度必须一致,就像一张另外自己的表,且交换分区,一张表不能为分区表)

tutorial=> create table gh_one_partition (id int,name varchar(35),dw_date date)                   
partition by range (dw_date)                                                                       (partition  p2015 start ('2015-01-01'::date) end ('2016-01-01'::date),                              partition  p2016 start ('2016-01-01'::date) end ('2017-01-01'::date));NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column named 'id' as the Greenplum Dat
abase data distribution key for this table.HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen
are the optimal data distribution key to minimize skew.NOTICE:  CREATE TABLE will create partition "gh_one_partition_1_prt_p2015" for table "gh_one_partit
ion"NOTICE:  CREATE TABLE will create partition "gh_one_partition_1_prt_p2016" for table "gh_one_partit
ion"CREATE TABLE

tutorial=> insert into gh_one_partition values(1,26,'2015-01-01'::date);
INSERT 0 1
tutorial=> insert into gh_one_partition values(1,26,'2015-02-01'::date);
INSERT 0 1
tutorial=> select * from gh_one_partition;
id | name |  dw_date  
----+------+------------
  1 | 26   | 2015-01-01
  1 | 26   | 2015-02-01
(2 rows)


tutorial=> select * from gh_partition_range_1_prt_p2015;
id | name | dw_end_date
----+------+-------------
(0 rows)

tutorial=> select * from gh_partition_range;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2016-01-01
  1 | 25   | 2016-01-01
  1 | 25   | 2016-02-01
  1 | 25   | 2016-06-01
  1 | 25   | 2016-07-01
(5 rows)

tutorial=> insert into gh_partition_range_1_prt_p2015 values(1,21,'2015-01-01'::date);
INSERT 0 1
tutorial=> select * from gh_partition_range_1_prt_p2015;
id | name | dw_end_date
----+------+-------------
  1 | 21   | 2015-01-01
(1 row)

tutorial=> select * from gh_one_partition_1_prt_p2015;
id | name |  dw_date  
----+------+------------
  1 | 26   | 2015-01-01
  1 | 26   | 2015-02-01
(2 rows)


tutorial=> alter table gh_partition_range exchange partition p2015 with table gh_one_partition;
ERROR:  relation "gh_one_partition" must have the same column names and column order as "gh_partition_range"
tutorial=> ALTER TABLE public.gh_one_partition RENAME dw_date  TO dw_end_date;
ALTER TABLE
tutorial=> alter table gh_partition_range exchange partition p2015 with table gh_one_partition;
ERROR:  cannot EXCHANGE table "gh_one_partition" as it has child table(s)
tutorial=> alter table gh_one_partition drop partition p2016;
ALTER TABLE
tutorial=> alter table gh_partition_range exchange partition p2015 with table gh_one_partition;
ERROR:  cannot EXCHANGE table "gh_one_partition" as it has child table(s)
tutorial=> create table gh_one_partition2 as select * from gh_one_partition;
NOTICE:  Table doesn't have 'DISTRIBUTED BY' clause -- Using column(s) named 'id' as the Greenplum
Database data distribution key for this table.HINT:  The 'DISTRIBUTED BY' clause determines the distribution of data. Make sure column(s) chosen
are the optimal data distribution key to minimize skew.SELECT 2
tutorial=> alter table gh_partition_range exchange partition p2015 with table gh_one_partition;
ERROR:  cannot EXCHANGE table "gh_one_partition" as it has child table(s)
tutorial=> alter table gh_partition_range exchange partition p2015 with table gh_one_partition2;
ERROR:  child table "gh_one_partition2" has different type for column "name"
tutorial=> alter table gh_partition_range exchange partition p2015 with table gh_one_partition2;
ALTER TABLE
tutorial=> select * from gh_one_partition2;
id | name | dw_end_date
----+------+-------------
  1 | 21   | 2015-01-01
(1 row)

tutorial=> select * from gh_partition_range_1_prt_p2015;
id | name | dw_end_date
----+------+-------------
  1 | 26   | 2015-01-01
  1 | 26   | 2015-02-01
(2 rows)

tutorial=> truncate tabel gh_one_partition2;
ERROR:  syntax error at or near "gh_one_partition2"
LINE 1: truncate tabel gh_one_partition2;
                       ^
tutorial=> truncate table gh_one_partition2;
TRUNCATE TABLE
tutorial=> alter table gh_partition_range exchange partition p2015 with table gh_one_partition2;
ALTER TABLE
tutorial=> select * from gh_one_partition2;
id | name | dw_end_date
----+------+-------------
  1 | 26   | 2015-01-01
  1 | 26   | 2015-02-01
(2 rows)

tutorial=> select * from gh_partition_range;
id | name | dw_end_date
----+------+-------------
  1 | 23   | 2016-01-01
  1 | 25   | 2016-01-01
  1 | 25   | 2016-02-01
  1 | 25   | 2016-06-01
  1 | 25   | 2016-07-01
(5 rows)

tutorial=>


范围分区每个间隔都要写,可以简化写法
every

tutorial=> create table gh_partition_every (id int,name varchar(32),dw_end_date date)             
distributed by (id)                                                                                partition by range (dw_end_date)                                                                   (                                                                                                  partition p2015 start ('2015-01-01'::date) end ('2019-01-01'::date)                                every ('1 years'::interval)                                                                        );
NOTICE:  CREATE TABLE will create partition "gh_partition_every_1_prt_p2015_1" for table "gh_partit
ion_every"NOTICE:  CREATE TABLE will create partition "gh_partition_every_1_prt_p2015_2" for table "gh_partit
ion_every"NOTICE:  CREATE TABLE will create partition "gh_partition_every_1_prt_p2015_3" for table "gh_partit
ion_every"NOTICE:  CREATE TABLE will create partition "gh_partition_every_1_prt_p2015_4" for table "gh_partit
ion_every"CREATE TABLE
tutorial=>


tutorial=> insert into gh_partition_every values(1,1,'2018-01-01'::date);
INSERT 0 1
tutorial=> insert into gh_partition_every values(1,1,'2017-01-01'::date);
INSERT 0 1
tutorial=> insert into gh_partition_every values(1,1,'2016-01-01'::date);
INSERT 0 1
tutorial=> insert into gh_partition_every values(1,1,'2015-01-01'::date);
INSERT 0 1
tutorial=> insert into gh_partition_every values(1,1,'2014-01-01'::date);
ERROR:  no partition for partitioning key  (seg0 slave1:40000 pid=2464)
tutorial=> insert into gh_partition_every values(1,1,'2019-01-01'::date);
ERROR:  no partition for partitioning key  (seg0 slave1:40000 pid=2464)
tutorial=>


tutorial=> select * from gh_partition_every;
id | name | dw_end_date
----+------+-------------
  1 | 1    | 2015-01-01
  1 | 1    | 2016-01-01
  1 | 1    | 2017-01-01
  1 | 1    | 2018-01-01
(4 rows)

tutorial=>


list分区
tutorial=> create table gh_partition_list(id int,name varchar(32),status varchar(10))
tutorial-> distributed by (id)
tutorial-> partition by list (status)
tutorial-> (
tutorial(> partition p_list_1 values ('weifang','qingdao'),
tutorial(> partition p_list_2 values ('taiyuan','datong'),
tutorial(> default partition other_city);
NOTICE:  CREATE TABLE will create partition "gh_partition_list_1_prt_p_list_1" for table "gh_partit
ion_list"NOTICE:  CREATE TABLE will create partition "gh_partition_list_1_prt_p_list_2" for table "gh_partit
ion_list"NOTICE:  CREATE TABLE will create partition "gh_partition_list_1_prt_other_city" for table "gh_part
ition_list"CREATE TABLE
tutorial=> insert into gh_partition_list values (1,1,'shanghai'),(2,2,'weifang');
INSERT 0 2
tutorial=> select * from gh_partition_list_1_prt_p_list_1;
id | name | status 
----+------+---------
  2 | 2    | weifang
(1 row)

tutorial=> select * from gh_partition_list_1_prt_p_list_2;
id | name | status
----+------+--------
(0 rows)

tutorial=> select * from gh_partition_list_1_prt_other_city ;
id | name |  status 
----+------+----------
  1 | 1    | shanghai
(1 row)

tutorial=>



分区表参数

pg_partition:分区主表

tutorial=> \d pg_partition;
    Table "pg_catalog.pg_partition"
    Column     |    Type    | Modifiers
---------------+------------+-----------
parrelid      | oid        | not null
parkind       | "char"     | not null
parlevel      | smallint   | not null
paristemplate | boolean    | not null
parnatts      | smallint   | not null
paratts       | int2vector | not null
parclass      | oidvector  | not null
Indexes:
    "pg_partition_oid_index" UNIQUE, btree (oid)
    "pg_partition_parrelid_index" btree (parrelid)
    "pg_partition_parrelid_parlevel_istemplate_index" btree (parrelid, parlevel, paristemplate)

tutorial=> select parrelid,parkind from pg_partition;
parrelid | parkind
----------+---------
    85849 | r
    86189 | r
    86445 | r
    86613 | l
(4 rows)

tutorial=> select relname from pg_class where oid ='public.gh_partition_range'::regclass;
      relname      
--------------------
gh_partition_range
(1 row)

tutorial=> select relname from pg_class where oid =85849;
      relname      
--------------------
gh_partition_range
(1 row)


tutorial=> \d pg_partition_rule;
   Table "pg_catalog.pg_partition_rule"
      Column       |   Type   | Modifiers
-------------------+----------+-----------
paroid            | oid      | not null
parchildrelid     | oid      | not null
parparentrule     | oid      | not null
parname           | name     | not null
parisdefault      | boolean  | not null
parruleord        | smallint | not null
parrangestartincl | boolean  | not null
parrangeendincl   | boolean  | not null
parrangestart     | text     |
parrangeend       | text     |
parrangeevery     | text     |
parlistvalues     | text     |
parreloptions     | text[]   |
partemplatespace  | oid      |
Indexes:
    "pg_partition_rule_oid_index" UNIQUE, btree (oid)
    "pg_partition_rule_parchildrelid_index" btree (parchildrelid)
    "pg_partition_rule_parchildrelid_parparentrule_parruleord_index" btree (parchildrelid, parparen
trule, parruleord)    "pg_partition_rule_paroid_parentrule_ruleord_index" btree (paroid, parparentrule, parruleord)


tutorial=> select paroid, parchildrelid , parname from pg_partition_rule ;
paroid | parchildrelid |  parname  
--------+---------------+------------
  85920 |         86106 | p2016s
  85920 |         86153 | p2016x
  86260 |         86212 | p2015
  85920 |         85872 | p2015
  86564 |         86468 | p2015_1
  86564 |         86492 | p2015_2
  86564 |         86516 | p2015_3
  86564 |         86540 | p2015_4
  86707 |         86636 | p_list_1
  86707 |         86660 | p_list_2
  86707 |         86684 | other_city
(11 rows)

tutorial=> select relname from pg_class where oid=86106;
             relname            
---------------------------------
gh_partition_range_1_prt_p2016s







范围分区支持max吗?
目前没有sql语法,无法测试,不过按照语句start end 应该不行




范围分区支持split吗?
范围分区支持split

范围分区各个分区索引可以不同吗?

Command:     CREATE INDEX
Description: define a new index
Syntax:
CREATE [UNIQUE] INDEX name ON table
       [USING btree|bitmap|gist]
       ( {column | (expression)} [opclass] [, ...] )
       [ WITH ( FILLFACTOR = value ) ]
       [TABLESPACE tablespace]
       [WHERE predicate]

查询创建索引语句没有所谓全局索引,本地索引的创建语句 

删除分区会对其他分区的索引有影响吗?

既然为本地索引,那么就可以认为删除分区对其他分区索引无影响









目录
相关文章
|
数据采集 API 开发者
快手商品数据采集接口
快手商品数据采集接口
|
存储 SQL Cloud Native
深入了解云原生数据库CockroachDB的概念与实践
作为一种全球领先的分布式SQL数据库,CockroachDB以其高可用性、强一致性和灵活性等特点备受关注。本文将深入探讨CockroachDB的概念、设计思想以及实践应用,并结合实例演示其在云原生环境下的优越表现。
|
10月前
|
人工智能 网络协议 机器人
2026年OpenClaw(原ClawdBot)部署接入QQ/飞书/钉钉/微信喂饭教程(阿里云专属,零基础保姆级)
2026年,OpenClaw(原ClawdBot,曾用名Moltbot)凭借“自然语言驱动+多任务自动化执行+全渠道适配”的核心优势,成为开源AI智能体赛道的现象级项目,GitHub星标数突破18.6万,吸引了无数个人用户和企业团队投身部署使用。作为一款定位为“真正能干事情的AI”,OpenClaw的核心价值不仅在于自动化办公、代码辅助、网页抓取等基础功能,更在于其强大的多渠道对接能力——可无缝接入QQ、飞书、钉钉、微信(喂饭模式)四大主流通讯工具,让AI助理突破Web控制台的限制,融入日常聊天场景,实现“聊两句就能下达指令、完成任务”。
3488 6
|
11月前
|
存储 弹性计算 关系型数据库
阿里云服务器及其他云产品免费试用活动解析:160多款产品支持试用,先试后用
阿里云推出涵盖160多款云产品的免费试用活动,覆盖计算、数据库、存储、网络与安全、大数据与AI等全场景。活动包含个人/企业版云服务器ECS(最高8核16G配置)、轻量应用服务器(预装宝塔面板等镜像)、RDS数据库(MySQL/PostgreSQL版)、对象存储OSS等核心产品,提供300元-660元试用金、流量包及企业级规格试用。
839 12
|
缓存 监控 Java
《深入理解Spring》性能监控与优化——构建高性能应用的艺术
本文系统介绍了Spring生态下的性能监控与优化实践,涵盖监控体系构建、数据库调优、缓存策略、线程池配置及性能测试等内容,强调通过数据驱动、分层优化和持续迭代提升应用性能。
|
存储 安全 Android开发
HarmonyOS实战:一招搞定保存图片到相册
本文介绍了在鸿蒙系统中实现保存图片到相册的功能,包括申请权限和使用系统安全控件两种方式。文中详细讲解了如何通过网络请求下载图片并保存为本地文件,以及如何将指定布局生成图片并保存。鸿蒙系统对权限管理较为严格,推荐使用系统提供的安全控件(如 SaveButton)以保护用户隐私,避免手动申请权限。此外,文章还对比了鸿蒙与 Android/iOS 的实现差异,指出鸿蒙在功能实现上更简单,但需注意权限规范以确保项目顺利上线。
1726 0
HarmonyOS实战:一招搞定保存图片到相册
|
人工智能 自然语言处理 搜索推荐
Spark-TTS: AI语音合成的"变声大师"
Spark-TTS 是一款革命性的语音合成模型,被誉为“变声大师”。它通过创新的 BiCodec 技术将语音分解为语义和全局两种 Token,实现对音色、性别、语速等属性的精细控制。结合统一的 LLM 架构,Spark-TTS 简化了传统 TTS 的复杂流程,同时提供了前所未有的灵活性。此外,团队还发布了 VoxBox 开源数据集,为行业提供标准评估基准。尽管在零样本场景下仍存改进空间,但 Spark-TTS 已经开启了语音合成新时代,让个性化、可控的 AI 语音成为可能。
1350 5
|
存储 安全 Linux
离线Linux服务器环境搭建
【9月更文挑战第3天】在离线环境下搭建Linux服务器需按以下步骤进行:首先确定服务器用途及需求,准备安装介质与所需软件包;接着安装Linux系统并配置网络;然后设置系统基础参数,如主机名与时区;安装必要软件并配置服务;最后进行安全设置,包括关闭非必要服务、配置防火墙、强化用户认证及定期备份数据。整个过程需确保软件包的完整性和兼容性。
762 3
|
算法 人机交互 调度
进程调度算法_轮转调度算法_优先级调度算法_多级反馈队列调度算法
轮转调度算法(RR)是一种常用且简单的调度方法,通过给每个进程分配一小段CPU运行时间来轮流执行。进程切换发生在当前进程完成或时间片用尽时。优先级调度算法则根据进程的紧迫性赋予不同优先级,高优先级进程优先执行,并分为抢占式和非抢占式。多队列调度算法通过设置多个具有不同优先级的就绪队列,采用多级反馈队列优先调度机制,以满足不同类型用户的需求,从而优化整体调度性能。
1438 15
|
缓存 安全 Java
Java中 final、finally、finalize 有什么区别?
本文详细阐述了Java中`final`、`finally`和`finalize`的区别:`final`用于修饰类、方法和变量以表示不可变性;`finally`是用于确保在`try-catch`结构中无论是否发生异常都能执行的代码块;而`finalize`是`Object`类的方法,用于在对象被垃圾回收前执行清理工作,但在JDK 9中已被标记为弃用。
894 0
Java中 final、finally、finalize 有什么区别?

热门文章

最新文章