I know that we can set up the "update" option when we create a database, but can we change that option in the future like after we already created the database?
You cannot change the "update" option after you created the database.
Related
I am looking for the possibility to capture the name of a table on CREATE TABLE, DROP TABLE and other operations in my postgres database.
I looked into event triggers and they seem to only be able to capture these events on ddl_command_end (https://www.postgresql.org/docs/current/functions-event-triggers.html#PG-EVENT-TRIGGER-SQL-DROP-FUNCTIONS), which should work for the CREATE case but not all of the others.
So I wanted to ask, if there exists a possibility to either get the data from a dropped table (as I would need it) or get the information before the event happens.
Thank you for your help!
In Oracle we have a option to recover table but in PostgreSQL we do not have that option. Only thing you can do for this kind of situation enabling archiving and following PITR steps. It could be on other server or on the server that your database running. It depends on significance of the dropped table and the database.
I have made some changes to a database using code first entity framework migrations (lets say db2).
I now want to revert the change made back to the original database. As we want to retain the data on the old database (db1) I cant simple clone it.
Can someone please confirm the right process to do this?
I am assuming I will need to perform a rollback on db2 back to the original state it was in when it was cloned from db1.
I would then switch context so I am pointing at db1.
I then add a migration to generate all the database changes.
I then perform update-database to run make the changes.
Is this correct?
I will then need to run a migration to br
You can use –TargetMigration parameter in order to migrate to a specific version:
Update-Database –TargetMigration: db1
More info.
I need our end-users to "clone" a database from our web application UI. I am able to "clone" a database by backing up a source database and restoring it into a new database. In this way, I "clone" the table schema and data.
My question is - is there any way I can "clone" just the table schema, without the data? I am aware that we can script the database manually, and run that script. But our table schema changes frequently (we add new columns and tables regularly) and we wouldn't want to update this script. Thank you.
basically you have to:
save the datatase
restore the backup to a new database (use the with move option)
connect to the new database and then exec sys.sp_MSforeachtable 'truncate table ?'
PS: you may have to disable FK constraints if any.
Antother solution: use Entity Framework Database First to build a small program. Launch said program with a connection string pointing to a new db.
Right Click over database -> Tasks -> Generate Script
On Set Scripting Options page click Advanced
General -> Types of data to script = Schema Only
With SQL Server data tools you can generate the schema difference and apply only the changes to target database.
what is the best way to replicate tables from oracle database on primary server to similar database on secondary server and vice versa.
i have tried using oracle streams but issue is i have triggers on tables and my requirement is to replicate data from these tables to database on secondary server and vice versa.As soon as the data is inserted in tab1 of sourceDB same is updated in tab2 of destiDB also the trigger on tab1 of destieDB gets triggered .This triggers should not triggered
basic idea being data availability.
Please suggest if this is correct way or i need to use some other way
You can use GoldenGate with SUPPRESSTRIGGERS option.
But it depends on your oracle version (not working on 11.1).
Adding DBOPTIONS SUPPRESSTRIGGERS to your replicat process configuration will prevent the trigger being executed on the target DB.
You could code the triggers in a way you can disable it on a per User or per Session basis see Stack Overflow: Disable Trigger per Session
But the better solution for a variety of concurrency and data consistency problems would be to use a professional backup/mirroring solution.
I need to create a SQL Server database that will recieve updates by some replication mechanism from another database. I need to write insert, update and delete triggers that will execute when this replilcation occurs.
I have experience with triggers but not with replication.
Should I use Transactional or Merge replication, or does it matter?
Will a trigger designed to run when a simple SQL insert statement is executed also run when replication occurs?
The CREATE TRIGGER syntax on MSDN:
CREATE TRIGGER
...
[ NOT FOR REPLICATION ]
This indicates that executing on replication is the default behaviour for triggers, and can be disabled by specifying NOT FOR REPLICATION.
Well it depends.
If the updates that you intend to apply are to isolated tables i.e. all the data for a given table comes from the publisher only, then you can use transactional replication.
If on the other hand you are looking to combine table content i.e. an orders table, with orders being placed at both sites, then you would want to look into using merge replication.
With regard to triggers, there is a "not for replication" configuration that you can apply to control their behaviour. See the following article for reference.
http://msdn.microsoft.com/en-us/library/ms152529.aspx
Cheers, John
It's hard to answer your question with the information you've provided. I added a few comments to your question asking for clarifying information.
Here is an article on MSDN that should help: http://msdn.microsoft.com/en-us/library/ms152529.aspx
By default, triggers will fire during replication unless "NOT FOR REPLICATION" is specified. They work the same way as they do for simple insert statements.
Transactional and Merge replication are very different, but triggers behave similarly for both options.
There are a few alternative options open to you instead of triggers.
You could modify the replication procedures on the subscriber (destination) database.
If using 2008 you can use Change Tracking on the subscriber for tables you want to "do something with" and then create a batch process to deal with "set based" data instead of invididual rows. E.g. an SSIS package that runs every X.