Oracle中,为什么删除表分区后公共同义词会失效

发布于 2024-07-11 22:14:52 字数 2011 浏览 12 评论 0原文

有人可以告诉我为什么会发生以下行为(Oracle 10.2):

SQL> create table part_test (
        i int primary key,
        d date
)
partition by range (d) (partition part_test_1 values less than (to_date('  2    3    4    5  1980-01-01', 'yyyy-mm-dd')));

create public synonym part_test for part_test;

select object_name, object_type, status from all_objects where object_name = 'PART_TEST';

alter table part_test add partition part_test_2 values less than (to_date('1981-01-01', 'yyyy-mm-dd'));

select object_name, object_type, status from all_objects where object_name = 'PART_TEST';

alter table part_test drop partition part_test_1;

select object_name, object_type, status from all_objects where object_name = 'PART_TEST';

drop public synonym part_test;
drop table part_test;

Table created.

SQL> SQL> 
Synonym created.

SQL> SQL> 
OBJECT_NAME                    OBJECT_TYPE         STATUS
------------------------------ ------------------- -------
PART_TEST                      TABLE               VALID
PART_TEST                      TABLE PARTITION     VALID
PART_TEST                      SYNONYM             VALID

SQL> SQL> 
Table altered.

SQL> SQL> 
OBJECT_NAME                    OBJECT_TYPE         STATUS
------------------------------ ------------------- -------
PART_TEST                      TABLE               VALID
PART_TEST                      TABLE PARTITION     VALID
PART_TEST                      TABLE PARTITION     VALID
PART_TEST                      SYNONYM             VALID

SQL> SQL> 
Table altered.

SQL> SQL> 
OBJECT_NAME                    OBJECT_TYPE         STATUS
------------------------------ ------------------- -------
PART_TEST                      TABLE               VALID
PART_TEST                      TABLE PARTITION     VALID
PART_TEST                      SYNONYM             INVALID

SQL> SQL> 
Synonym dropped.

SQL> 
Table dropped.

SQL> 

删除分区后同义词变得无效,我无法弄清楚为什么。

感谢您的任何想法。

can someone tell me why the following behavior occurs (Oracle 10.2):

SQL> create table part_test (
        i int primary key,
        d date
)
partition by range (d) (partition part_test_1 values less than (to_date('  2    3    4    5  1980-01-01', 'yyyy-mm-dd')));

create public synonym part_test for part_test;

select object_name, object_type, status from all_objects where object_name = 'PART_TEST';

alter table part_test add partition part_test_2 values less than (to_date('1981-01-01', 'yyyy-mm-dd'));

select object_name, object_type, status from all_objects where object_name = 'PART_TEST';

alter table part_test drop partition part_test_1;

select object_name, object_type, status from all_objects where object_name = 'PART_TEST';

drop public synonym part_test;
drop table part_test;

Table created.

SQL> SQL> 
Synonym created.

SQL> SQL> 
OBJECT_NAME                    OBJECT_TYPE         STATUS
------------------------------ ------------------- -------
PART_TEST                      TABLE               VALID
PART_TEST                      TABLE PARTITION     VALID
PART_TEST                      SYNONYM             VALID

SQL> SQL> 
Table altered.

SQL> SQL> 
OBJECT_NAME                    OBJECT_TYPE         STATUS
------------------------------ ------------------- -------
PART_TEST                      TABLE               VALID
PART_TEST                      TABLE PARTITION     VALID
PART_TEST                      TABLE PARTITION     VALID
PART_TEST                      SYNONYM             VALID

SQL> SQL> 
Table altered.

SQL> SQL> 
OBJECT_NAME                    OBJECT_TYPE         STATUS
------------------------------ ------------------- -------
PART_TEST                      TABLE               VALID
PART_TEST                      TABLE PARTITION     VALID
PART_TEST                      SYNONYM             INVALID

SQL> SQL> 
Synonym dropped.

SQL> 
Table dropped.

SQL> 

The synonym becomes invalid after partitions are dropped, and I can't work out why.

Thanks for any thoughts.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

奈何桥上唱咆哮 2024-07-18 22:14:52

我已经用 Oracle 10.2 对其进行了测试,同义词确实变得无效,但是当其他用户通过执行

select count(*) from part_test;

来使用同义词时 Oracle自动编译同义词并且同义词生效。

包、过程和函数也是如此。 当你执行它们并且它们无效时,Oracle会尝试自动编译它们。

I have tested it with Oracle 10.2 and the synonym becomes indeed invalid but when an other user uses the synonym by doing

select count(*) from part_test;

Oracle automatically compiles the synonym and the synonym becomes valid.

It is the same with packages, procedures and functions. When you execute them and they are invalid, Oracle will try to compile them automatically.

荒芜了季节 2024-07-18 22:14:52

11.1.0.6 中没有
这可能是一个已修复的错误。 这可能是必要的(例如,根据同义词重新验证视图......),但使用了改进的技术。

It doesn't in 11.1.0.6
It could have been a bug that was fixed. It may have been something that was necessary (eg for revalidating a view based on a synonym...) but where an improved technique has been used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文