Oracle中,为什么删除表分区后公共同义词会失效
有人可以告诉我为什么会发生以下行为(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经用 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.
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.