我用 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 会不会对数据库产生什么其他影响?望赐教
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 会不会对数据库产生什么其他影响?望赐教
早上我执行了个错误的语法create or replace public synonym student for user_1.student 就变成上面所说的情况了;
我查了备份数据库,原来的table_owner 就是 user_2...现在就是要把它变回来
所有用户都可以使用该同义词(前提是它有访问同义词所指的原始对象的权限),
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;
create public synonym student for user_2.student;
可以么
OWNER ——此同义词的拥有者,也就是创建者
TABLE_OWNER——同义词参照的对象的拥有者
你得有目的地去创建,比如为scott用户下的emp表创建一个公共同义词,
让所有的用户都可以访问此表
--下面是视图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