Re: [firebird-support] Restore without constraints

2015-10-24 Thread Köditz, Martin martin.koed...@it-syn.de [firebird-support]
Hi Mark,

I don't want to delete the column, just the constraint. So I can add a new PK. 
Since there are several FKs referencing to that PK, I have to delete the FKs 
first. That is the main problem. I'm just looking for a method to delete all 
constraints. After that I can cleanly add new ones.

Regards
Martin


Re: [firebird-support] Restore without constraints

2015-10-24 Thread Mark Rotteveel m...@lawinegevaar.nl [firebird-support]
On 22-10-2015 11:20, Köditz, Martin martin.koed...@it-syn.de 
[firebird-support] wrote:
> is it possible to restore a database without constraints? Or is there
> another way to do this? I just want do delete each primary key in the db.

Could you explain exactly what you are trying to achieve? For example, 
if you say "delete each primary key", do you mean deleting the column, 
setting the value to null, or dropping the primary key constraint?

Mark
-- 
Mark Rotteveel


Re: [firebird-support] Restore without constraints

2015-10-24 Thread Köditz, Martin martin.koed...@it-syn.de [firebird-support]
Hi Rik,

thank you for the info. This helps a lot. The reason why I want to delete the 
constraints are wrong namings.

The process is following:

1.  Delete foreign keys

2.  Delete primary keys

3.  Create new keys

I think I can do that via execute blocks as you have shown.

Regards
Martin


Re: [firebird-support] Restore without constraints

2015-10-23 Thread Rik van Kekem r...@graficalc.nl [firebird-support]
Köditz, Martin martin.koed...@it-syn.de [firebird-support] wrote:
> is it possible to restore a database without constraints? Or is there
> another way to do this? I just want do delete each primary key in the db.

Is this on a healthy DB? I'm not sure if -I disables the constraints in 
that case. You can use -I -N. (-N for disabling the constraints). After 
that you can remove the primary records.
See http://www.firebirdsql.org/manual/gbak-cmdline.html

But then what If you activate the indexes and constraints again you 
face the same problem (you can't because of the sub-records).

If the DB was build correctly there should have been a ON DELETE CASCADE 
on the constraint. Maybe you still can change the constraints with a ON 
DELETE CASCADE. Removing the records from the primary table will delete 
all sub-records too.


Either way... with this you can activate all indexes and constraints 
again (but only if you also deleted the sub-records with the foreign keys):

EXECUTE BLOCK AS
DECLARE VARIABLE stmt VARCHAR(1000);
BEGIN
for select 'ALTER INDEX '||rdb$index_name ||' ACTIVE;'
from rdb$indices
where (rdb$system_flag is null or rdb$system_flag = 0)
order by rdb$foreign_key nulls first
into :stmt
do EXECUTE STATEMENT :stmt;
END






++

Visit http://www.firebirdsql.org and click the Documentation item
on the main (top) menu.  Try FAQ and other links from the left-side menu there.

Also search the knowledgebases at http://www.ibphoenix.com/resources/documents/ 

++


Yahoo Groups Links

<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/firebird-support/

<*> Your email settings:
Individual Email | Traditional

<*> To change settings online go to:
http://groups.yahoo.com/group/firebird-support/join
(Yahoo! ID required)

<*> To change settings via email:
firebird-support-dig...@yahoogroups.com 
firebird-support-fullfeatu...@yahoogroups.com

<*> To unsubscribe from this group, send an email to:
firebird-support-unsubscr...@yahoogroups.com

<*> Your use of Yahoo Groups is subject to:
https://info.yahoo.com/legal/us/yahoo/utos/terms/



RE: [firebird-support] Restore without constraints

2015-10-22 Thread Köditz, Martin martin.koed...@it-syn.de [firebird-support]
I've done that. But the keys still exist and I'm not able to delete them while 
there are many dependencies. Maybe the only chance is to delete the foreign 
keys first and then the primary keys. Or is there a more graceful way?

Regards
Martin


RE: [firebird-support] Restore without constraints

2015-10-22 Thread 'Neil Pickles' neil.pick...@csy.co.uk [firebird-support]
You just need to use the -i switch with gbak when restoring the database. We
use this when we have a database that has become corrupted and we are then
fixing it with gfix and when it comes to restoring it, it fails due to some
issue with either missing or duplicated data

 

Cheers,

Neil Pickles - n...@csy.co.uk