473,796 Members | 2,619 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Check integrity

Hi,

What methods can we use to check the integrity problems? Some records in my
database are having Foreign Keys but the database doesn't have any related
records with required Primary Keys. I need to scan the whole database and
delete (maybe with backup, maybe not) all wrong records.

Who can I do that? Is it need to write my own application to do that or we
have some standard way to fix these problems? I'm not a database
administrator and don't know these ways (yet). Can somebody help me with
advice?

Thanks.

Dmitri Shvetsov

Jul 20 '05 #1
4 5431
Hi

If you have a foreign key constraint enabled for the given relationships
then this should not occur.
If they were created with the NOCHECK option then existing data may violate
the constraint, but if you would not be able to create the FK if you this
was the case and NOCHECK was not specified.

The easiest way to check the integrity is probably to drop and reapply the
FKs. Another alternative would be to use a construct such as

SELECT * FROM Referencing C WHERE NOT EXISTS ( SELECT * FROM Referenced P
WHERE P.PK = C.FK )

But doing this for a large database may take some time.

John

"Dmitri Shvetsov" <ds*******@cox. net> wrote in message
news:Xzlnb.8799 9$Ms2.54382@fed 1read03...
Hi,

What methods can we use to check the integrity problems? Some records in my database are having Foreign Keys but the database doesn't have any related
records with required Primary Keys. I need to scan the whole database and
delete (maybe with backup, maybe not) all wrong records.

Who can I do that? Is it need to write my own application to do that or we
have some standard way to fix these problems? I'm not a database
administrator and don't know these ways (yet). Can somebody help me with
advice?

Thanks.

Dmitri Shvetsov

Jul 20 '05 #2
Hi

If you have a foreign key constraint enabled for the given relationships
then this should not occur.
If they were created with the NOCHECK option then existing data may violate
the constraint, but if you would not be able to create the FK if you this
was the case and NOCHECK was not specified.

The easiest way to check the integrity is probably to drop and reapply the
FKs. Another alternative would be to use a construct such as

SELECT * FROM Referencing C WHERE NOT EXISTS ( SELECT * FROM Referenced P
WHERE P.PK = C.FK )

But doing this for a large database may take some time.

John

"Dmitri Shvetsov" <ds*******@cox. net> wrote in message
news:Xzlnb.8799 9$Ms2.54382@fed 1read03...
Hi,

What methods can we use to check the integrity problems? Some records in my database are having Foreign Keys but the database doesn't have any related
records with required Primary Keys. I need to scan the whole database and
delete (maybe with backup, maybe not) all wrong records.

Who can I do that? Is it need to write my own application to do that or we
have some standard way to fix these problems? I'm not a database
administrator and don't know these ways (yet). Can somebody help me with
advice?

Thanks.

Dmitri Shvetsov

Jul 20 '05 #3
MC
Try using dbcc checkconstraint s with all_constraints . It should return all
'bad' data in the database...

MC

"Dmitri Shvetsov" <ds*******@cox. net> wrote in message
news:Xzlnb.8799 9$Ms2.54382@fed 1read03...
Hi,

What methods can we use to check the integrity problems? Some records in my database are having Foreign Keys but the database doesn't have any related
records with required Primary Keys. I need to scan the whole database and
delete (maybe with backup, maybe not) all wrong records.

Who can I do that? Is it need to write my own application to do that or we
have some standard way to fix these problems? I'm not a database
administrator and don't know these ways (yet). Can somebody help me with
advice?

Thanks.

Dmitri Shvetsov

Jul 20 '05 #4
MC
Try using dbcc checkconstraint s with all_constraints . It should return all
'bad' data in the database...

MC

"Dmitri Shvetsov" <ds*******@cox. net> wrote in message
news:Xzlnb.8799 9$Ms2.54382@fed 1read03...
Hi,

What methods can we use to check the integrity problems? Some records in my database are having Foreign Keys but the database doesn't have any related
records with required Primary Keys. I need to scan the whole database and
delete (maybe with backup, maybe not) all wrong records.

Who can I do that? Is it need to write my own application to do that or we
have some standard way to fix these problems? I'm not a database
administrator and don't know these ways (yet). Can somebody help me with
advice?

Thanks.

Dmitri Shvetsov

Jul 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
9073
by: RAD | last post by:
I am working with an evaluation copy of SQL Server 2000 for the first time; my DB experience lies with MS Access. I have a simple table in SQL Server (tblCompany) that has a field called "Ticker." When new company stock tickers (i.e., MSFT for Microsoft) are entered into the field, I'd like them in all caps--whether the user types msft, Msft, MsFt, etc. In Access, this was easy--simply set the Format to ">" in table design view. In...
2
9987
by: Brice | last post by:
Hello, Sorry if this is a basic question but I can't seem to find the answer in the DB2 tutorial series or my DB2 manuals. How does one check the data integrity and referential integrity of an instance before running a backup? I see how one can run "db2ckbkp" after the backup has run, and I've seen some discussion of checksums in past postings, but what I'm looking for is more of: #!/bin/sh
3
11113
by: Stephen | last post by:
This is probably something simple but I've been trying for a while now and can't seem to get it. I'm loading a table from an IXF file with the following command 'load from D:/db_scripts/load_test/nlm.ixf of ixf modified by USEDEFAULTS method n (NOTIFY_LIST_ID,PUBLICATION_ID) insert into mediaadm.NOTIFY_LIST_MEMBERS' this works fine but afterwards the table goes into a 'check pending'
1
5962
by: huyuhui | last post by:
The following is a question of LOAD utility. Question: How does the DB2 enforce table check constraints for data added to table with the LOAD utility? A. With the BUILD phase of LOAD B. With the SET INTEGRITY statement C. With the DELETE phase of the LOAD D. With the UPDATE CONSTRAINTS statement Answer is A
16
5670
by: Brian Tkatch | last post by:
Is there a way to check the order in which SET INTEGRITY needs to be applied? This would be for a script with a dynamic list of TABLEs. B.
1
7182
by: giftson.john | last post by:
Hi, Anybody knows how to check the file integrity? I need to check the file integrity whether it is corrupt or not. Can anyone please advice?
6
10761
by: Hemant Shah | last post by:
Folks, One of our clients is performing an audit, and the auditor(s) asked following question, and I am not sure how to answer it: 28. Is there a control that prevents the corruption of databases (e.g. is there database integrity checking)? Please provide a description of the control and the name and phone number of the person who can demonstrate or validate the control.
1
3852
by: amitabh.mehra | last post by:
If I drop some constraints on a table by 'alter table..' query, does this table go into check pending state? If no, then what is the way to put this table into check pending state other than using the SET INTEGRITY statement?
0
924
by: Joell | last post by:
Hi Guys, I have set up an Integrity check on two different maintenance plans. Set up the same on both however one works, one fails. There is no error message either other than the job failed. I have this integrith check on our system database maintenance plan. Any ideas to the error or what to check off on the menus? Joell
0
9685
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10461
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10239
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10190
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9057
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7555
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6796
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5447
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4122
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.