sql logics1

  • 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

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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

  • asranantha (8/16/2012)


    answere is 28 rows

    You sure?

  • 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

  • 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

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • 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

  • why isbbelle gets erroe

    and williams inserts 2 rows +julianna insert 12 rows are not lodead in in toy table how u say thatone

  • asranantha (8/16/2012)


    why isbbelle gets erroe

    and 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.

  • asranantha (8/16/2012)


    why isbbelle gets erroe

    and 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lynn Pettis (8/16/2012)


    asranantha (8/16/2012)


    why isbbelle gets erroe

    and 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

  • asranantha (8/16/2012)


    why isbbelle gets erroe

    and 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


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Lowell (8/16/2012)


    asranantha (8/16/2012)


    why isbbelle gets erroe

    and 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