Re: onDelete cascade after table has been created
From: Jerry Stuckle <jstucklex_at_attglobal.net>
Date: Sat, 20 Feb 2016 10:21:03 -0500
Message-ID: <naa038$8pm$2_at_jstuckle.eternal-september.org>
>> On 02/20/2016 07:10 AM, apoorv.kanungo_at_gmail.com wrote:
>>> Hello I know we can use cascading while creating table but After I created table and there are bunch of data in it how would I do ondelete cascade.
>>
>> You have specified that delete rows when the user is deleted
>>
>> delete from user where id = 12
>>
>>
>> will delete the rows in article too. No extra queries to execute or
>> other commands, you have already defined the behaviour when you created
>> the tables, without the on delete cascade, you wouldn't be able to
>> delete the user until you had deleted the articles first.
>>
>>
>> --
>>
>> //Aho
Date: Sat, 20 Feb 2016 10:21:03 -0500
Message-ID: <naa038$8pm$2_at_jstuckle.eternal-september.org>
On 2/20/2016 4:40 AM, apoorv.kanungo_at_gmail.com wrote:
> On Saturday, February 20, 2016 at 2:27:09 PM UTC+5:30, J.O. Aho wrote:
>> On 02/20/2016 07:10 AM, apoorv.kanungo_at_gmail.com wrote:
>>> Hello I know we can use cascading while creating table but After I created table and there are bunch of data in it how would I do ondelete cascade.
>>
>> You have specified that delete rows when the user is deleted
>>
>> delete from user where id = 12
>>
>>
>> will delete the rows in article too. No extra queries to execute or
>> other commands, you have already defined the behaviour when you created
>> the tables, without the on delete cascade, you wouldn't be able to
>> delete the user until you had deleted the articles first.
>>
>>
>> --
>>
>> //Aho
> > Hi there I did not provide on delete Cascade when I create table but after table has been created if i delete delete from user where id=4 and I would like to delete entry in article table with user_id=4 but its not the case as it does not get deleted from article table. >
Are you sure your ALTER TABLE was correct and it worked? What do you get when you do
SHOW TABLE article;
-- ================== Remove the "x" from my email address Jerry Stuckle jstucklex_at_attglobal.net ==================Received on Sat Feb 20 2016 - 16:21:03 CET