How to automatically ad/drop a table on an existing replication?

Hi!
I would like to have a replication for my database (in SQL Server 2008 R2), which automatically add/drop tables at the subscriber (without needing me to manually change the publication properties and articles items) as soon as I add/drop at the publisher.
Can anyone help me on that?
Regards
Amin

Change the immediate_sync property of your publication to be false.
To do this - do this:
sp_changepublication 'MyPublication','allow_anonymous',false
GO
sp_changepublication 'MyPublication','immediate_sync',false
GO
Then add new tables to your publication using this
sp_addarticle 'MyPublication', table3, @Source_object=table3
GO
sp_refreshsubscriptions 'MyPublication'
GO
sp_startpublication_snapshot 'MyPublication'
GO
Now to make this automatic you will need to run a job that will detect the new table added or a table deletion and then have it run the sp_addarticle, sp_refershsubscriptions, and sp_startpublication_snapshot commands.
To drop a table you would issue a sp_dropsubscription and sp_droparticle statements like this:
sp_dropsubscription 'MyPublication','ArticleIWishToDrop', Subscriber, SubsriberDatabase
GO
sp_droparticle 'MyPublication','ArticleIWishToDrop'
You will need to add this to a job as well. This will not drop the table on the subscriber, it will just stop replicating changes to this table to the subscriber.
looking for a book on SQL Server 2008 Administration?
http://www.amazon.com/Microsoft-Server-2008-Management-Administration/dp/067233044X looking for a book on SQL Server 2008 Full-Text Search?
http://www.amazon.com/Pro-Full-Text-Search-Server-2008/dp/1430215941

Similar Messages

  • How to find who  dropped the table

    Hi Gurus,
    Is there a way beside auditing to know who dropped the table,i know we could use logminer for that but the thing is that i don't have supplemental logging turned on while the table got dropped.
    I think we need to have supplemental logging enabled to find who did what even for the DDL correct?
    Is there any way i can find who dropped the table?
    Thanks

    user9097501 wrote:
    Hi Gurus,
    Is there a way beside auditing to know who dropped the table,i know we could use logminer for that but the thing is that i don't have supplemental logging turned on while the table got dropped.
    I think we need to have supplemental logging enabled to find who did what even for the DDL correct?
    Is there any way i can find who dropped the table?
    ThanksI can think about 2 different ways to do it ;
    1- by using Audit http://www.oracle-base.com/articles/10g/Auditing_10gR2.php ; if it's enabled
    2- or there another method , does not give a real precision, but could be helpful if the audit is not enabled ; can be to check listener log. Listener does show database connection requests. So if you know the time the table was dropped (SELECT DROPTIME
    FROM DBA_RECYCLEBIN
    WHERE Owner = 'XXX'
    AND ORIGINAL_NAME= 'YYYYYY'), you can see from the listener log what connected to the database at that time. (asuming that the connection request was from a remote client, not the DB server)
    E.g if I found that the table were dropped at 14:45:18 then I can tell from my listener log that it is probably due to a user connected by the portal application on host portal.es6.orawiss.net:
    23-AUG-2010 14:45:18 * (CONNECT_DATA=(SID=DB02)(CID=(PROGRAM=httpd)(HOST=portal.es6.orawiss.net)(USER=apache))) * (ADDRESS=(PROTOCOL=tcp)(HOST=192.168.44.30)(PORT=60618)) * establish * DB02 * 0
    Listener logs are an important source of audit information.
    Hope it helps :)

  • How to find out if a table is in the replication process?

    Hi, I'm trying to figure out if one of the table in the database is replicated from outside. What should I do to find out this? Can anyone help me out? Thanks a lot! _meg                                                                                                                                                                                                                                                                                                                                                       

    Try this query
    select gname,oname,status from dba_repobject where oname='TABLE_NAME';

  • How to create and drop partitions automatically?

    How to create and drop partitions automatically?
    The environment is Oracle 10g(10.2.0.3) on the RHEL4.0 system.
    I want to partition the MESSAGE table by date (NUMTODSINTERVAL(1,'DAY') ). One partition per day. Because the table is huge, only 2 partitions (today and yesterday's data) are necessary to be kept online. All the partitions that earlier than the previous day will be backed up and then dropped. I want to make the partition creating and dropping jobs run automatically. How to do it?
    Thank you

    junez wrote:
    How to create and drop partitions automatically?
    The environment is Oracle 10g(10.2.0.3) on the RHEL4.0 system.
    I want to partition the MESSAGE table by date (NUMTODSINTERVAL(1,'DAY') ). One partition per day. Because the table is huge, only 2 partitions (today and yesterday's data) are necessary to be kept online. All the partitions that earlier than the previous day will be backed up and then dropped. I want to make the partition creating and dropping jobs run automatically. How to do it?With 11g, new partitions can automatically be created.
    With 10g, you need to do that yourself. I prefer to create a "buffer" of future partitions - in case the job whose task it is to add new partitions gets held up or stuck. Or the job queue is full due to some problem and it does not get the chance to execute in time.
    I dislike your partitioning criteria. I prefer using the date directly and not mangling it to something else. If a specific day has a large volume of data, then another option is to use hourly date ranged partitions. With local partitioned indexes and the date time range used for querying, this can be quite effective performance wise.
    As for partitioning maintenance - I use a custom written partitionManager PL/SQL package that provides an interface for adding daily and hourly partitions to a table. Input parameters are for example name of the table, start date and the number of partitions to add. Similarly it provides interfaces for aging partitions - again by specifying a table and a date-time to use as the starting point, back into time, for removing old partitions.
    I typically call this code from the actual application code itself - so before a new partition will be used for example, the app code will first ensure that it has a partition to use. This is safer than a separate job as the dependency is resolved where and when it is needed - and not done as a separate task.
    For example - you should have a procedure/package that provides an app the means to log a message into your MESSAGE table. As part of an autonomous transaction, this procedure can check if the required partition exists, before attempting to insert a message into the table.
    Where this approach is not possible, a DBMS_JOB can be used to create future partitions - but as I mentioned, rather have it add a bunch of future (empty) partitions in case something goes pear shape with the job mechanism.

  • How to find the user who dropped the tables

    Hi All,
    Some one has dropped 5 tables in the production database that has caused a SEV1 but thankfully we are having those tables in recyclebin and we are restored those with out data loss.
    But I want to know who has dropped those tables and want to know who has connected to database at that time. Can you please guide me in this how to find out....
    Database version: 11.2.0.2 version
    Thanks
    Kk
    Edited by: 908098 on Jan 18, 2012 4:23 AM

    Or you can use this kind of audit (i had used this some time ago)
    -is pretty detailed but is good for auditing purpuse.
    hope this helps
    CREATE TABLE AUDITORIA_ESQUEMA (
    operation VARCHAR2(30),
    os_user VARCHAR2(30),
    obj_owner VARCHAR2(30),
    object_name VARCHAR2(30),
    object_type VARCHAR2(30),
    sql_text     VARCHAR2(64),
    attempt_by VARCHAR2(30),
    attempt_dt DATE,
    Ip_adress VARCHAR2(15));
    CREATE OR REPLACE TRIGGER AUDITORIA_ESQUEMA
    BEFORE CREATE OR ALTER OR DROP OR RENAME or alter
    ON DATABASE
    DECLARE
    oper varchar2(200);
    sql_text ora_name_list_t;
    i      PLS_INTEGER;
    BEGIN
    SELECT ora_sysevent
    INTO oper
    FROM DUAL;
    i := sql_txt(sql_text);
    IF oper IN ('CREATE', 'DROP','RENAME','ALTER') THEN
         INSERT INTO AUDITORIA_ESQUEMA
         SELECT ora_sysevent,(select sys_context('USERENV','OS_USER') from dual)
    , ora_dict_obj_owner,
         ora_dict_obj_name,ora_dict_obj_type, sql_text(1), USER, SYSDATE,
         (select SYS_CONTEXT('USERENV', 'IP_ADDRESS') from dual)
         FROM DUAL;
    ELSIF oper = 'ALTER' THEN
         INSERT INTO AUDITORIA_ESQUEMA
         SELECT ora_sysevent,(select sys_context('USERENV','OS_USER') from dual)
    , ora_dict_obj_owner,
         ora_dict_obj_name,ora_dict_obj_type, sql_text(1), USER, SYSDATE,
         (select SYS_CONTEXT('USERENV', 'IP_ADDRESS') from dual)
         FROM sys.gv_$sqltext
         WHERE UPPER(sql_text) LIKE 'ALTER%'
         AND UPPER(sql_text) LIKE '%NEW_TABLE%';
    END IF;
    END AUDITORIA_ESQUEMA;

  • How to restore a dropped table when recycle bin is purged??

    how to restore a dropped table when recycle bin is purged??

    You should be asking general database questions in General Questions - and not in the Objects forum.
    Restoring a dropped table means restoring a logical or physical backup of that table.

  • How can recover the dropped table on oracle 9i and 10g ?

    This is the scnario...
    user dropped one table on his schema...
    oracle 10g DB
    flashback not enabled so no flashback drop possible
    but any way to recover it from recyclebin on 10g ? becuase this is not sysdba table ...if yes how about on 9i...if yes then will there be any limit on recycle bin like space pressure ??
    Scnario 2:
    we have two online redo log group with 2 member each..
    my currnet online redolog group currupted (including members)...we need the data's of that currnet group so we should'nt use the clear log command
    how to recover it ?
    Do we need to go for any block level revcovery ?
    thanks
    Moorthy
    Edited by: user13014926 on Jan 18, 2011 6:55 AM

    If you have no backup your only option is to perform incomplete recovery (point-in-time recovery) to the time just before the drop, export the table and then restore the database (for example, from a cold backup taken just before the incomplete recovery,) and import the table. This obviously requires a full backup
    taken before the drop which you don't seem to have, so the answer is "regrettably no."
    If you have a backup;
    Take backup of ur current db, apply previous day backup, do point in time recovery to get table back,export table, shutdown and apply latest backup, import table back
    Regards,

  • How to Rollback a Dropped Table

    Hi
    How i do i rollback from a dropped table?
    I have created a sample table as follows
    begin transaction
    create table sample_t1
    (id int,
    class nvarchar(100),
    subject nvarchar(100))
    INSERT INTO sample_t1 VALUES(10,'XYZ','LKJ')
    INSERT INTO sample_t1 VALUES(10,'XYZ','LKJ')
    INSERT INTO sample_t1 VALUES(10,'XYZ','LKJ')
    INSERT INTO sample_t1 VALUES(10,'XYZ','LKJ')
    INSERT INTO sample_t1 VALUES(10,'XYZ','LKJ')
    SELECT * FROM sample_t1
    DROP TABLE sample_t1
    ROLLBACK ----> "when this command is issued, it says commands compelted successfully in the message area , but when i check through select * from sample_t1, it says " invalid object name sample_t1"
    Please help

    Hi Visakhm
    Thanks for your help on this.You have helped me get back the dropped table.
    However, in case my colleague drops a table without issuing
    "BEGIN TRANSACTION" command or the followed command "go"  and just directly drops a table using " drop table tablename"
    and how i can get this table back ?
    If you do not have transaction specified, you can not rollback the transaction.
    If you have log backup in place, you may be able to restore the database backups. Refer the below link for the same: http://social.msdn.microsoft.com/Forums/en-US/16efd46d-eba9-4f9a-8683-f55caa3b4ffa/restore-differential-database-backup-with-on-daily-basis?forum=databasedesign
    Top of all, Better option would be  DO NOT give permission to drop the tables to your colleagues. 

  • How to drop multiple tables in SQL Workshop

    Hi,
    I'd like to drop multiple tables in one time but
    SQL command processor returnes error message: ORA-00933.
    Could you please tell me how to drop multiple tables in
    one time?
    My trial was follows
    Drop table "table1", "table2"
    Result
    ORA-00933: SQL command not properly ended
    Regards,
    Hideki Sakamoto

    Hideki,
    SQL syntax permits you to specify only one table in a DROP TABLE command.
    The SQL Command Processor permits you to run one statement or PL/SQL block per submission.
    So there are at least two ways you can do this. You could either upload or create a SQL script in SQL Workshop which contains your multiple statements:
    drop table "table1"
    drop table "table2"
    or you could execute a single anonymous PL/SQL block in the SQL Command Processor, as in:
    begin
    execute immediate 'drop table "table1"';
    execute immediate 'drop table "table2"';
    end;
    Joel

  • When I drop a table, automatic creating dummy tables

    Hi, All
    I am using 11g
    in this, whnever i drop a table , Oracle automatically creates 1 table like this name ("BIN$ja1wOa6kYLPgQAB/AQB5ZQ==$0")
    This table i am not able to drop
    Even , when i see in enterprise console these table are not showing
    But when i am seeing through SqlPlus it is showing the name in table list
    pls. provide any solution
    Thanks in advance
    pankaj

    user11308301 wrote:
    Hi, All
    I am using 11g
    in this, whnever i drop a table , Oracle automatically creates 1 table like this name ("BIN$ja1wOa6kYLPgQAB/AQB5ZQ==$0")
    This table i am not able to drop
    Even , when i see in enterprise console these table are not showing
    But when i am seeing through SqlPlus it is showing the name in table list
    pls. provide any solution
    Thanks in advance
    pankajThis is called recyclebin. Dropped tables goes into the recyclebin, and can be restored from the recyclebin.
    If you dropped table with PURGE option, it would not go into recyclebin.
    To drop object from recyclebin itself, use SQL>purge table "BIN$ja1wOa6kYLPgQAB/AQB5ZQ==$0" ;

  • How to automatically build a table with 2 alternated font colors for the lines ?

    Hi,
    I'm looking for a way to automatically build a table with alternate background color and alternate font color for the lines.
    I have this particular project (a list of companies of an industrial area) and it is updated twice a year :
    I managed to set an automated alternate background color of the lines so this works well (white/blue/white/blue...)
    But the font color does not automatically alternates... and I do not know how to set this up...
    All the companies are ordered alphabetically so when I have to insert or delete one, the whole text of the table under the modified line is messed up. Then I have unreadable white text on white background and blue text on blue background...
    Does anyone have an idea on how to automatically alternate the font color ?
    Thank you.
    Best regards,
    G.

    Hi,
    I know this [JS] code is awful but it works. If  someone wants to correct it …! 
    At the beginning, you have an Excel file. You play a little with it [doing concatenations] to get, after importing it in ID:
    Then, just run the .jsx:
    Done! 

  • How to drop the tables (articles) in subscription database MERGE replication.

    We have configured the merge replication from publication server to subscription server,
    Here I mistakenly selecting few tables (articles) in publication,
    Now I need to remove those mistakenly selected tables in subscription server database . 
    Note: I am trying to below way but unable to remove those tables in subscription server.
    1<sup>st</sup> I unselected those tables (articles) in publication, but not working.
    Could please tell me the how to remove those tables in subscription database.

    Ok that is normal, dont worry, if you mistakenly  chosen few tables, just add the new tables
    that you forgot it, just make click on the publication, you only have to Re-run the snapshot agent, i mean you must generate another snapshot and then synchronice with your suscriber, and then you will not need DROP the tables on the suscriber, if you have
    troubles yet, please post imagens to help you more !
    Thanks and regards.

  • How to drop multiple tables in one statement

    I could used to run the below syntax to drop multiple tables in MS SQL, but it doesn't work in Oracle seems like, I am using free Oracle SQL Developer. Not a big deal but wanna know if this can be done. Thanks,
    DROP TABLE A, B, C, D, F

    I'm not so sure in 1 select statement is it possible or not but you can try to use in this manner to see what happens ->
    drop table &tab;
    Enter value for tab: A
    Table A Successfully dropped.
    Enter value for tab: B
    Table B Successfully dropped.Regards.
    Satyaki De.

  • How to drop all tables in perticular schema??

    Hi,
    I am new in oracle.
    I want to drop all tables in one perticular schema,
    Please tell me solution.
    PratHamesh

    If your few of your tables have referential intigrity constraints and trying to drop master table whithout droping child table first, oracle will produce an error.
    Better option would be to drop the entire schema and then create a new schema with the same name.
    on sql plus.
    set long size 20000
    select dbms_metadata.get_ddl('USER','USERNAME') from dual;
    --then save the above output to create the user later.
    drop username cascade
    use the above saved script to create the user again.
    Jaffar

  • How to drop a table in another schema.

    Hi there, was looking to drop a table that is currently created under GL schema when consolidation process is done. These tables are kind of temporary and stay there if consolidation process doesn't complete successfully.
    So, I'm try to execute a script that would drop the table but the particularity is that this drop isn'T executed by apps but with bolinf (custom user).
    So, while trying to delete it with bolinf, I always get an error message that the table doesn't exists or so.
    Here's the code
    r_gl_int_ctrl.INTERFACE_TABLE_NAME is retreived from gl_interface_control table and from INTERFACE_TABLE_NAME column.
    EXECUTE IMMEDIATE 'DROP TABLE GL.' || r_gl_int_ctrl.INTERFACE_TABLE_NAME;
    and this generates the following error : ORA-00942: table or view does not exist
    R12.0.6
    RDBMS 10.2.0.3.0
    Custom package under bolinf schema is trying to drop GL.GL_CONS_INTERFACE_38190 and it's not working. Nevertheless, if I install this package under apps, table get dropped.
    Is there a way that I can drop a GL table like GL.GL_CONS_INTERFACE_38190 from BOLINF schema ? If so, what privileges/grant should user BOLINF have in order to drop this table from a GL Schema ?
    Thank you.

    Hi;
    You need to give drop grant to your user.Easy way is to give
    GRANT DROP ANY TABLE TO USER; << but its mean it will give drop grant for all table.
    Also see:
    OERR: ORA 942 "table or view does not exist" [ID 18536.1]
    Regard
    Helios

Maybe you are looking for

  • Java API's supported in the Jdeveloper, IAS, and RDBMS product components

    If there are any technical errors or "mistatement of the facts" in this posting, please let me know about them .. This article is being delivered in Draft form and may contain errors. Please use the MetaLink "Feedback" button to advise Oracle of any

  • ITunes Problems on W XP

    Wondering if anyone can suggest a solution to a problem I have created with running iTunes on my Dell desktop PC with Windows XP? With the computer suffering from a lenghty set-up time when signing in, I decided to delete some unnessary Spyware from

  • Can't silently install app with icons

    Hi, I need to silently install an application that has desktop icons with an indication whether the installation succeeded or failed. First of all, it seems that unless I use -silent, javaws will not indicate success or failure. However, if I use -si

  • HT3597 commands for voice control

    Is there a list of commands for voice control?

  • CS4 downloaded raw 5.7 still cant open cr2 files on windows 8 HELP!!!

    Does CS4 work ok on windows 8 I have purchased a new windows 8 laptop and installed CS4 and I could not open my CR2 files so I downloaded raw 5.7  convertor and still nothong can you please help.