12c新特性不可用列小测试 -m6米乐安卓版下载

原创 云和恩墨 2022-05-09
640

一、创建测试表

scott@orcl> create table t2(id int,name varchar2(20),pho number);
table created.
scott@orcl> insert into t2 values(1,'scott',13888888888);
1 row created.
scott@orcl> commit;
commit complete.
scott@orcl> desc t2;
 name                                                                                  null?    type
 ------------------------------------------------------------------------------------- -------- ----------------------------------------------------------
 id                                                                                             number(38)
 name                                                                                           varchar2(20)
 pho   
scott@orcl> select * from t2;
        id name                                                      pho
---------- -------------------------------------------------- ----------
         1 scott                                              1.3889e 10

二、创建视图和同义词

scott@orcl> create view t_v  as select * from t2;
view created.
scott@orcl> alter table t2 set unused(pho);
table altered.
scott@orcl> select * from t_v;
select * from t_v
              *
error at line 1:
ora-04063: view "scott.t_v" has errors
scott@orcl> alter table t2 add pho number;
table altered.
scott@orcl> update t2 set pho=13888888888 where id=1;
1 row updated.
scott@orcl> commit;
commit complete.
scott@orcl> select * from t_v;
        id name                                                      pho
---------- -------------------------------------------------- ----------
         1 scott                                              1.3889e 10
scott@orcl> create synonym t_s for t2;
synonym created.
scott@orcl> alter table t2 set unused(pho);
table altered.

三、标记为不可见

scott@orcl> alter table t2 set unused(pho);
alter table t2 set unused(pho)
                          *
error at line 1:
ora-00904: "pho": invalid identifier
scott@orcl> select * from t_s;
        id name
---------- --------------------------------------------------
         1 scott
scott@orcl> select * from t_v;
select * from t_v
              *
error at line 1:
ora-04063: view "scott.t_v" has errors

同义词可见视图不可见,同义词是别名,视图因为依赖关系,已经失效

四、添加列

scott@orcl> alter table t2 add pho number;
table altered.
scott@orcl> update t2 set pho=13888888888 where id=1;
1 row updated.
scott@orcl> commit;
commit complete.
scott@orcl> select * from t2;
        id name                                                      pho
---------- -------------------------------------------------- ----------
         1 scott                                              1.3889e 10
scott@orcl> select * from t_v;
        id name                                                      pho
---------- -------------------------------------------------- ----------
         1 scott                                              1.3889e 10

五、试试索引

scott@orcl>  alter table t2 add pho number;
table altered.
scott@orcl> update t2 set pho=13888888888 where id=1;
1 row updated.
scott@orcl> commit;
commit complete.
scott@orcl> create index idx_t2 on t2(pho);
scott@orcl> col index_name for a20
scott@orcl> select index_name,status from user_indexes;
index_name           status
-------------------- ----------------
idx_t2               valid
scott@orcl> alter table t2 set unused(pho);
table altered.
scott@orcl> select index_name,status from user_indexes;
no rows selected

一起消失了

scott@orcl> alter table t2 add pho number;
table altered.
scott@orcl> update t2 set pho=13888888888 where id=1;
1 row updated.
scott@orcl> commit;
commit complete.
scott@orcl> select index_name,status from user_indexes;
no rows selected
scott@orcl> create index idx_t2 on t2(pho);
index created.
scott@orcl> select index_name,status from user_indexes;
index_name           status
-------------------- ----------------
idx_t2               valid
最后修改时间:2022-05-10 08:05:04
「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【米乐app官网下载的版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

网站地图