Showing posts with label behavior. Show all posts
Showing posts with label behavior. Show all posts

Wednesday, March 7, 2012

Delete/truncate table ignoring contraints

Is there any easy way to truncate a table which has a foreign key restraint? I want to override the default behavior which is to not allow truncate of parent tables. I want to be able to temperarily remove the contraint so I can truncate the temple, how do you do this?

I should add that the systables keep track of the contraints. There should be a query that I could run that would just disable the checking of the contraint? Any help?|||No. There is no way to control/alter the behavior of truncate table. If you need to use it you have to drop the FK constraints even if the table is empty.|||

O.K. So... that isn't easily done.

Is there any easy way to simply copy the schema, contraints and everything but simply no data? Perhaps using DTS?

Or perhaps, is there another way to reset the identity information of a table? The delete operator does not reset identity.

|||If you want to reset identity value you can use DBCC CHECKIDENT. See Books Online for more details. Your original question was different.||| your original question was different

:) Thanks.

Delete Update Behavior of the SSEv Engine

Can someone on the team tell me if a delete or update orphans a row in the SQL Server Everywhere database that must be compacted out to free the space? I understand that Compact runs automatically when the last connection is closed but does this create another copy of the database as it does with JET or is this an update-in-place. Is this an opportunity to corrupt the database if the process is interrupted by power-failure or a truck running over the device from right-to-left?

Hmm..I think there is some misunderstanding here. When the last connection to database is closed COMPAT IS NOT RUN automatically. There is a similar thing called 'Auto Shrink' that runs if the space available (and sparse) is more than a threshold. COMPACT need to be run explicitly. When you run COMPACT, you can specify the destination database. The destination database can also be same as the source database file. In any case, the compaction first happens into a temp database file, the original file deleted, the temp files gets renamed.

Thanks,

Laxmi

Delete Update Behavior of the SSEv Engine

Can someone on the team tell me if a delete or update orphans a row in the SQL Server Everywhere database that must be compacted out to free the space? I understand that Compact runs automatically when the last connection is closed but does this create another copy of the database as it does with JET or is this an update-in-place. Is this an opportunity to corrupt the database if the process is interrupted by power-failure or a truck running over the device from right-to-left?

Hmm..I think there is some misunderstanding here. When the last connection to database is closed COMPAT IS NOT RUN automatically. There is a similar thing called 'Auto Shrink' that runs if the space available (and sparse) is more than a threshold. COMPACT need to be run explicitly. When you run COMPACT, you can specify the destination database. The destination database can also be same as the source database file. In any case, the compaction first happens into a temp database file, the original file deleted, the temp files gets renamed.

Thanks,

Laxmi