【发布时间】:2022-10-17 14:52:17
【问题描述】:
标签: yugabytedb
标签: yugabytedb
是的。
yugabyte=# dt
List of relations
Schema | Name | Type | Owner
--------+-----------------------+-------+----------
public | order_changes | table | yugabyte
public | order_changes_2019_02 | table | yugabyte
public | order_changes_2019_03 | table | yugabyte
public | order_changes_2020_11 | table | yugabyte
public | order_changes_2020_12 | table | yugabyte
public | order_changes_2021_01 | table | yugabyte
public | people | table | yugabyte
public | people1 | table | yugabyte
public | user_audit | table | yugabyte
public | user_credentials | table | yugabyte
public | user_profile | table | yugabyte
public | user_svc_account | table | yugabyte
(12 rows)
yugabyte=# alter table order_changes RENAME TO oc;
ALTER TABLE
yugabyte=# dS+ oc
Table "public.oc"
Column | Type | Collation | Nullable | Default | Storage | Stats target | Description
-------------+------+-----------+----------+---------+----------+--------------+-------------
change_date | date | | | | plain | |
type | text | | | | extended | |
description | text | | | | extended | |
Partition key: RANGE (change_date)
Partitions: order_changes_2019_02 FOR VALUES FROM ('2019-02-01') TO ('2019-03-01'),
order_changes_2019_03 FOR VALUES FROM ('2019-03-01') TO ('2019-04-01'),
order_changes_2020_11 FOR VALUES FROM ('2020-11-01') TO ('2020-12-01'),
order_changes_2020_12 FOR VALUES FROM ('2020-12-01') TO ('2021-01-01'),
order_changes_2021_01 FOR VALUES FROM ('2021-01-01') TO ('2021-02-01')
Postgres 和 YugabyteDB 实际上并不使用对象的名称,它使用对象的 OID(对象 ID)。
这意味着您可以重命名它,而实际上不会造成任何损害,因为它只是目录中的一个名称,其对象由其 OID 标识。
这也有其他副作用:如果您创建一个表,并执行某个 SQL,如“从表中选择 count(*)”,删除它,然后创建一个同名的表,并执行完全相同的 SQL,您将在 pg_stat_statements 中获得两条具有相同 SQL 文本的记录。从共享 SQL 区域的数据库的角度来看,这似乎很奇怪。在 postgres 中,只有 pg_stat_statements 是共享的,没有 SQL 缓存。
pg_stat_statements 不存储 SQL 文本,它存储查询树(SQL 的内部表示),并将树符号化,这使得再次看起来像 SQL。查询树使用 OID,因此对于 pg_stat_statements,上述两个相同的 SQL 文本是不同的查询树,因为表的 OID 不同。
【讨论】: