I have 2 databases and want to implement triggers on table update of database1 to do do some updates on database2's tables.
Example:
db1 has a table 1t1
db2 has a table 2t1
on inserting a touple into 1t1 i want to insert corresponding touple into 2t1
As of now Im using postgresql, but I dont mind switching to other free databases.
How to achieve this?
I suggest to use database link to establish a connection between two remote DB.
Take a look to this page:
http://www.postgresql.org/docs/current/static/contrib-dblink-connect.html
There is also a good tutorial here:
http://www.postgresonline.com/journal/archives/44-Using-DbLink-to-access-other-PostgreSQL-Databases-and-Servers.html
bye,
Andrea
If you could replace databases with schemas everything becomes easy.
Possibility of such replacement depends on why you have chosen databases as organisational units.
Postgresql 9.1 has a new feature called "foreign table":
http://www.postgresql.org/docs/9.1/static/sql-createforeigntable.html
Does that help maybe?
Related
I have below 2 approach to create Db in titanium. Need to know which is the best approach out of these 2.
Approach 1 -- Create a sqlite database using a tool like 'SQLite Manager' and copying that database to app and using it.
Approach 2 -- Create a sqlite database, using queries in the titanium code. like Ti.Database.open("DBName"); and then create tables using sqlite queries
thanks
amit
If the database is always going to be read-only, I'd go with #1. But if it will contain user entered data, you will eventually need to do #2 if you ever need to update the design of the database.
I've had apps that I needed to add features - that required new tables / indexes. You can't use approach #1 to modify a 'Version 1' database to your new design.
In some days ago...i was converting some Large MySQL Database to Oracle 10g R2 by using Oracle SQL Developer database migration tools.But unfortunately it was migrated on system schema.but i need to it on scott schema.
After Googling i found this two links OraFAQ Forum and ASK TOM Q&A.But I cannot find any appropriate answer. Any one Can help me to do , How it is possible.
Thanks In Advance.
IIRC the MySQL backup tool spits out plain SQL. As it would be in the form of fairly vanilla SQL -- just create and insert, I guess -- it ought to be able to be run against your Oracle schema with the minimum of alteration.
Having said that, in the SQL Developer migration wizard, the second step allows you to select the target schema. If you have a connection setup to scott, why doesn't that work for you?
If the table isn't too large (dependent upon your system resources and server horsepower etc.) then you could simply rebuild the table in the desired schema with the following.
N.B. You need to be logged in as either the target schema's user (with select permission on the table in the SYSTEM tablespace) or as system:
CREATE TABLE <newschema>.<tablename>
AS
SELECT *
FROM system.<tablename>;
Then remove the original table once the new table has been created.
If the table is large then you could use DATAPUMP to export and import it into the desired schema.
Here is an article on using Data Pump for this purpose:
http://oraclehack.blogspot.com/2010/06/data-pump-moving-tables-to-new-schema.html
Hope this helps
We are migrating database structures, so I have one database with the old structure and one database with the new structure (both on the same server). I want to write queries to copy data from one to the other. I am expecting to go table-by-table as the schema is different. How do I do this?
You need to provide more details to get a more specific answer, but in general you just use the three-part name:
INSERT INTO NewDB.dbo.TableName
SELECT <columns>
FROM OldDB.dbo.Tablename
Are you looking for a way to do this automatically for all the tables?
You can write cross database queries like so
INSERT INTO NewDatabase.Schema.Table
SELECT Column1, Column2
FROM OldDatabase.Schema.Table
you can probably use Import data under tasks.Right Click the Target DB -> Tasks ->Import Data .You can also specify the source-> target mapping here.. and also write queries
The company I work for uses a bunch of different SQL servers and I was wondering how to select a different SQL server in the same script.
For example, I want to select data from a table on a database in server 1 and using that data to get data from another table on a database in server 2. I tried googling the solution but I couldn't find anything relevant to my problem.
Thanks in advance.
You can set them up as linked servers.
http://msdn.microsoft.com/en-us/library/aa560998(v=bts.10).aspx
then you syntax will be
SERVERALIAS.DBNAME.owner.TABLE
Use fully qualified names (i.e. select * from [server].[database].[owner].[tablename])
Also, be sure to setup those servers as linked servers. There are several articles online how to do this.
I agree with Kyle & Flavio that You have to use four part naming convention to whatever server,database,table & column data like this:
Select * from [Servername].[Databasename].[Owner].[Tablename]
A cleaner option is to set up Synonyms to your linked servers. This way, you alias the server, and therefore don't have to hard code the 4 parts into every query.
If you hard code and later change a server's name, you will have to hunt down every reference and update. With Synonyms, all you'll have to do is update the applicable Synonym.
Synonyms give you transparent external tables, procedures, and UDFs.
MSDN here.
I had a notion to use a database column of type replication ID, but have since changed my approach and want to use this column for another purpose.
However, I'm unable to use SQL to drop the column to remove it from my database.
My SQL is:
ALTER TABLE foo_bar DROP COLUMN theFoo;
However, I get a "syntax error" and I'm assuming this has something to do with this column being a replication ID.
I'd rather not download the file and edit it directly using the MS Access application, but not sure if that's my only recourse.
Thanks so much in advance.
Regards,
Kris
If you have access to the database in a command shell, Michael Kaplan's Replication System Removal Fields utility should do the trick. However, I've found that in some circumstances, it's unable to do the job. Also note that the utility will only work with a Jet 4 format database (MDB), not ACE format (ACCDB).
If all else fails, you can recreate the table structure and append the existing data to it. That can get messy if you have referential integrity defined, though, but it will get the job done, and likely most of it is scriptable (if not all possible using just DDL).
Here is a link that may help you, I had a similar idea but when browsing the web found this
AccessMonster - Replication-ID-Field-size
EDIT: Well I don't have much time but what I was thinking of first was if you could alter the column to make it different (not a replication ID) and then drop it. (two separate actions). But I have not tested this.