внешние ключи на таблице от другой базы данных

Используйте эти script, команда в Вашем сценарии (человек 1 сценарий)

Создает сценарий оболочки обертки (2 строки), который настраивает сценарий () и затем называет выход.

Часть 1: часть 2 wrap.sh

#!/bin/sh
script -c './realscript.sh'
exit

: Результат realscript.sh

#!/bin/sh
echo 'Output'

:

~: sh wrap.sh 
Script started, file is typescript
Output
Script done, file is typescript
~: cat typescript 
Script started on fr. 12. des. 2008 kl. 18.07 +0100
Output

Script done on fr. 12. des. 2008 kl. 18.07 +0100
~:
15
задан OMG Ponies 14 September 2009 в 23:31
поделиться

3 ответа

I would avoid doing this if I could - can you just keep both tables in one datbase and use an FK?

Parent and Child Tables Are in Different Databases.

Although you cannot use a foreign key in this situation, there are workarounds – you can use either triggers or UDFs wrapped in check constraints. Either way, your data integrity is not completely watertight: if the database with your parent table crashes and you restore it from a backup, you may easily end up with orphans.

Parent-Child Relationship Is Enforced by Triggers.

There are quite a few situations when triggers do not fire, such as:

· A table is dropped.

· A table is truncated.

· Settings for nested and/or recursive triggers prevent a trigger from firing.

Also a trigger may be just incorrect. Either way, you may end up with orphans in your database.

7
ответ дан 1 December 2019 в 05:02
поделиться

Here's an article on how to use the SSIS Import / Export wizard:

http://www.databasejournal.com/features/mssql/article.php/3580216/SQL-Server-2005-Import--Export-Wizard.htm

The easiest way to do this is just to export one database (I'd use the smallest of the two) to whatever format is the most convenient for you, and then import it into the other. As long as the table names are all different, this shouldn't present any problem.

1
ответ дан 1 December 2019 в 05:02
поделиться

Триггеры могут быть написаны для обеспечения ссылочной целостности для различных баз данных.

1
ответ дан 1 December 2019 в 05:02
поделиться
Другие вопросы по тегам:

Похожие вопросы: