Showing posts with label synonym. Show all posts
Showing posts with label synonym. Show all posts

Monday, September 10, 2012

Create public synonyms for table, views, sequences

Create public synonyms for table, views, sequences for the schema XYZSchema


declare
  CURSOR xcur is
    select object_name, object_type from all_objects
where object_type IN ('TABLE', 'VIEW', 'SEQUENCE')
and owner = 'XYZSchema'
     ;

    xdat xcur%ROWTYPE;

begin
  for xdat in xcur loop
    begin
      execute immediate 'create or replace public synonym '|| xdat.object_name || ' for XYZSchema.'||xdat.object_name;
    exception when others
     then null;
    end;
   end loop;
 end;
/