August 16, 2012 at 1:35 am
hi firend i have small doubt in sql plz tell me answer
Auto commit has been turned off.
1- William logs into the database
2- Julianna logs into the database
3- William sees 12 rows in the TOYS table
4- Isabelle logs into the database
5- Julianna sees 12 rows in the TOYS table
6- William inserts two rows into the TOYS table
7- Julianna inserts 14 rows into the TOYS table
8- Isabelle issues a COMMIT
9- William issues a ROLLBACK
10- Julianna looks at the TOYS table
Based on the scenario above, how many rows does Julianna see in the TOYS table when she looks at it in step 10?
plz tell me the logic .and tell me the process
August 16, 2012 at 2:00 am
Interview question? Homework?
That's not hard to implement and test.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 16, 2012 at 5:00 am
how can u gues it is interview question? and in case of its interview question why ur not help?ok if u know answer tell me answers its help other wise donot comments unnecessary
August 16, 2012 at 5:21 am
Because it's blatantly obvious that it's a set question. We don't just give out answers to interview questions, it doesn't help you learn and I don't need the job.
Seriously, create a table, create three SSMS sessions and do what's in that list and see how many rows. You'll remember the answer (and possibly the reason) far better than if someone just gives you the answer.
Also, read up on transactions and rollbacks for the theory behind why it works
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 16, 2012 at 10:30 am
answere is 28 rows
here there is no logic just thinking
like this way
first step first persion enter to the database
in second step second persion enter to the database
in third step william sees 12 rows in the toys table that means toys table contain
12 rows
in fourt step third persion log on to the same database
in fifth step second persion sees 12 rows in the toys table that time also toys table
contains 12 rows
in sixth step first persion insert 2 rows into the toyps table that time toys table
contain 14 rows
in sevents step second persion insert 14 rows into the toys table that time toys table
contain 28 rows
in eighth step second persion issues the commit that means all rows are commit
so 28 rows are commit in toys table
in ninth step first pesion issue rollback that time also 28 rows avilable in toys table
in 10th step third persion look to toys table that time he sees 28 rows in toys table
August 16, 2012 at 10:38 am
asranantha (8/16/2012)
answere is 28 rows
You sure?
August 16, 2012 at 10:43 am
Second question... What does Isabelle see when she runs a commit? :w00t:
Also, the question is incomplete. Like asking how many car lengths are between me and that tree over there?... A car is not a unit of length. Looking at a table is not a defined construct. Querying a table is also not a defined construct, as there are several ways to structure that query.
Jared
CE - Microsoft
August 16, 2012 at 10:55 am
So you're saying that if you and I are both making changes to a table at the same time, when you run a commit you also commit my changes and then if I decide that I want to undo my changes, I can't roll them back because you already committed them?
Sure that's how transactions work? (hint, look up the meaning of ACID as it applied to transactions, specifically what the I stands for and means)
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
August 16, 2012 at 11:02 am
1- William logs into the database
2- Julianna logs into the database
3- William sees 12 rows in the TOYS table
How does he "see" 12 rows? SELECT TOP 12? SELECT *? WITH(NOLOCK)? GUI?
4- Isabelle logs into the database
5- Julianna sees 12 rows in the TOYS table
Again... How does she "see" 12 rows? SELECT TOP 12? SELECT *? WITH(NOLOCK)? GUI?
6- William inserts two rows into the TOYS table
7- Julianna inserts 14 rows into the TOYS table
8- Isabelle issues a COMMIT
Isabelle gets an error...
9- William issues a ROLLBACK
10- Julianna looks at the TOYS table
Once again... How does she "see" 12 rows? SELECT TOP 12? SELECT *? WITH(NOLOCK)? GUI?
Jared
CE - Microsoft
August 16, 2012 at 11:24 am
why isbbelle gets erroe
and williams inserts 2 rows +julianna insert 12 rows are not lodead in in toy table how u say thatone
August 16, 2012 at 11:25 am
asranantha (8/16/2012)
why isbbelle gets erroeand williams inserts 2 rows +julianna insert 12 rows are not lodead in in toy table how u say thatone
Because Isabelle can't commit the transactions for Williams and Julianna. Only they can rollback or commit their updates.
August 16, 2012 at 11:35 am
asranantha (8/16/2012)
why isbbelle gets erroeand williams inserts 2 rows +julianna insert 12 rows are not lodead in in toy table how u say thatone
that's EXACTLY why you need to follow gails advice and open three seperate windows(the equivilent of each user logging in, and do the steps step by step;
then you'll see for yourself why, as well as help build yourself a framework for testing similar scenarios in the future.
I firmly believe that only by experiencing it will you learn from it. Enlightenment comes from within, not from people just giving you the answer of 42 (or whatever it really is)
Lowell
August 16, 2012 at 11:36 am
Lynn Pettis (8/16/2012)
asranantha (8/16/2012)
why isbbelle gets erroeand williams inserts 2 rows +julianna insert 12 rows are not lodead in in toy table how u say thatone
Because Isabelle can't commit the transactions for Williams and Julianna. Only they can rollback or commit their updates.
What if William or Julianna get up from their desk, don't lock their machine, and then Isabelle swoops in and controls their sessions? 🙂
Jared
CE - Microsoft
August 16, 2012 at 11:38 am
asranantha (8/16/2012)
why isbbelle gets erroeand williams inserts 2 rows +julianna insert 12 rows are not lodead in in toy table how u say thatone
that's EXACTLY why you need to follow gails advice and open three seperate windows(the equivilent of each user logging in, and do the steps step by step;
then you'll see for yourself why, as well as help build yourself a framework for testing similar scenarios in the future.
I firmly believe that only by experiencing it will you learn from it. Enlightenment comes from within, not from people just giving you the answer of 42 (or whatever it really is)
whoops. I didn't notice where it was saying auto commit was turned off; my bad.
Lowell
August 16, 2012 at 11:42 am
Lowell (8/16/2012)
asranantha (8/16/2012)
why isbbelle gets erroeand williams inserts 2 rows +julianna insert 12 rows are not lodead in in toy table how u say thatone
that's EXACTLY why you need to follow gails advice and open three seperate windows(the equivilent of each user logging in, and do the steps step by step;
then you'll see for yourself why, as well as help build yourself a framework for testing similar scenarios in the future.
I firmly believe that only by experiencing it will you learn from it. Enlightenment comes from within, not from people just giving you the answer of 42 (or whatever it really is)
Also, be sure you use explicit transactions (i.e. start each insert with a BEGIN TRANSACTION).
Viewing 15 posts - 1 through 15 (of 16 total)
You must be logged in to reply to this topic. Login to reply