我用 select * from dba_synonyms where table_name= 'student' 结果如下    owner      synonym_name     table_owner      table_name
       public      student          user_1           student1.这里的owner 和 table_owner有什么区别?2.现在想把table_owner 改为 user_2
  我的语法是:    EXEC   sp_changeobjectowner   'student',   'user_2'
        或者:    EXEC   sp_changeobjectowner   'user_1.student','user_2' 都报错 (invalid sql statement)  
  正确的语法要如何写?3.这样修改Talbe_owner 会不会对数据库产生什么其他影响?望赐教

解决方案 »

  1.   

    这个表本来就属于user_1,,,,这个是系统视图。不能改
      

  2.   

    情况是这样的:
    早上我执行了个错误的语法create or replace public synonym student for user_1.student 就变成上面所说的情况了;
    我查了备份数据库,原来的table_owner 就是 user_2...现在就是要把它变回来
      

  3.   

    1、owner指的是同义词student的所属用户,如果是public则表明,
    所有用户都可以使用该同义词(前提是它有访问同义词所指的原始对象的权限),
    table_owner指的是表student所属的用户是user_12、系统没有sp_changeobjectowner存储过程。不要手工修改数据字典。3、你要想修改为user_2,这样
    在user_2下建立student表
    create table user_2.student as select * from user_1.student;
    删除原来的同义词
    drop synonym student;
    建立public的同义词
    create public synonym student for user_2.student;
      

  4.   

    做一个逆操作,只执行
    create public synonym student for user_2.student;
    可以么
      

  5.   

    你user_2下有student表么?如果有,当然可以。
      

  6.   

    1.这里的owner 和 table_owner有什么区别?
    OWNER ——此同义词的拥有者,也就是创建者
    TABLE_OWNER——同义词参照的对象的拥有者
      

  7.   

    2.同义词是为用户下的某个对象创建的,不是你想改就可以改的,
    你得有目的地去创建,比如为scott用户下的emp表创建一个公共同义词,
    让所有的用户都可以访问此表
      

  8.   


    --下面是视图dba_synonyms:
    SQL> desc dba_synonyms;
    Name         Type          Nullable Default Comments                                                 
    ------------ ------------- -------- ------- -------------------------------------------------------- 
    OWNER        VARCHAR2(30)                   Username of the owner of the synonym                     
    SYNONYM_NAME VARCHAR2(30)                   Name of the synonym                                      
    TABLE_OWNER  VARCHAR2(30)  Y                Owner of the object referenced by the synonym            
    TABLE_NAME   VARCHAR2(30)                   Name of the object referenced by the synonym             
    DB_LINK      VARCHAR2(128) Y                Name of the database link referenced in a remote synonym