Thanks that worked and I've just created a new wiki page with how to delete
all patients and patient data with this info

https://wiki.openmrs.org/display/docs/How+to+delete+or+erase+all+patients+and+patient+data+from+OpenMRS

Joaquín
___________________________________________________________________
Gerente de Desarrollo, eHealth Systems <http://www.ehs.cl/>
Research Fellow, Escuela de Medicina de Harvard <http://hms.harvard.edu/>
Moderador, GHDOnline.org <http://www.ghdonline.org/>


On Mon, Dec 19, 2011 at 7:03 PM, Darius Jazayeri <[email protected]>wrote:

> Joaquin,
>
> The foreign key is from users.person_id to person.person_id.
>
> So you need to do
>     delete from person where person_id not in (select person_id from
> users);
>
> -Darius
>
> On Mon, Dec 19, 2011 at 1:19 PM, Joaquín Blaya <
> [email protected]> wrote:
>
>> I'm trying to delete all patients from an OPenMRS instance and I've
>> deleted everything but the persons table. However, when I try this
>>
>> delete from person where person_id not in (select user_id from users);
>>
>> I get the following
>> ERROR 1451 (23000): Cannot delete or update a parent row: a foreign key
>> constraint fails (`openmrs/users`, CONSTRAINT `person_id_for_user` FOREIGN
>> KEY (`person_id`) REFERENCES `person` (`person_id`))
>>
>> How can this be if I specifically tell it not to include anyone in the
>> users table?  What should I be using to delete all persons not included in
>> users?
>>
>> Thanks,
>>
>>
>> Joaquín
>> ___________________________________________________________________
>> Gerente de Desarrollo, eHealth Systems <http://www.ehs.cl/>
>> Research Fellow, Escuela de Medicina de Harvard <http://hms.harvard.edu/>
>> Moderador, GHDOnline.org <http://www.ghdonline.org/>
>> ------------------------------
>> Click here to 
>> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-implement-l>from
>>  OpenMRS Implementers' mailing list
>
>
>  ------------------------------
> Click here to 
> unsubscribe<[email protected]?body=SIGNOFF%20openmrs-implement-l>from
>  OpenMRS Implementers' mailing list

_________________________________________

To unsubscribe from OpenMRS Implementers' mailing list, send an e-mail to 
[email protected] with "SIGNOFF openmrs-implement-l" in the  body 
(not the subject) of your e-mail.

[mailto:[email protected]?body=SIGNOFF%20openmrs-implement-l]

Reply via email to