Remove data from tables

  • Sorry for the error on choice d). I did test for each choices. Not sure how it happen. Could Steve Jones please change it from "delete table BBB" to "delete from BBB" for choice d)? Thanks.

    --------------------------------------
    ;-)“Everything has beauty, but not everyone sees it.” ― Confucius

  • Koen Verbeeck (3/5/2015)


    Hany Helmy (3/5/2015)


    Jostein Saethern (3/4/2015)


    The "delete table BBB;" statement in d) will fail.

    Its just a typo.

    That's not a typo, that is a mistake.

    DELETE FRAM BBB, that is a typo.

    Probably a copy/paste artifact (which some might categorize as a type of typo).

    Don Simpson



    I'm not sure about Heisenberg.

  • Option F ia good. Not sure how Mr Author is coming to option D...To my understanding neither C nor d is correct. Only one which comes to a good answer is optioon. f

    Thanks.

  • ondo (3/5/2015)


    Just a typo makes here difference if you answer correctly or not. I didn't pick d), because syntax was not correct ...

    +100

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Richard Warr (3/5/2015)


    We had no way of telling if DELETE TABLE meant DELETE FROM or DROP TABLE. Both would have worked though 🙂

    +1

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • chgn01 (3/5/2015)


    Sorry for the error on choice d). I did test for each choices. Not sure how it happen. Could Steve Jones please change it from "delete table BBB" to "delete from BBB" for choice d)? Thanks.

    And what about the explanation, where you wrongly state that Truncate isn't logged?

  • Toreador (3/6/2015)


    chgn01 (3/5/2015)


    Sorry for the error on choice d). I did test for each choices. Not sure how it happen. Could Steve Jones please change it from "delete table BBB" to "delete from BBB" for choice d)? Thanks.

    And what about the explanation, where you wrongly state that Truncate isn't logged?

    Delete command logs deleted rows, truncate command does not, though it's not the same as "Truncate isn't logged".

  • Mauricio_ (3/5/2015)


    I only marked option F). Option D) has a wrong syntax.

    +1

  • Yeah, the syntax error made this one get a second and third look. Since none of the others could work, it was the only one left. I half expected to get a "no, wrong answer" because only one of the answers was actually right, even though the question said to pick two.

  • Richard Warr (3/5/2015)


    We had no way of telling if DELETE TABLE meant DELETE FROM or DROP TABLE. Both would have worked though 🙂

    I had assumed that this was meaning DROP TABLE and as this removes the table as opposed to just the data from it would succeed but would not meet the requirements specified.

    f was obviously fine but I had assumed that b was fine also on the basis that truncating bbb would resolve the foreign key constraint. Thanks to Toreador for explaining why that does not work.

  • b) and f) are correct answer, as records from child is removed before parent. It is not mentioned any where that logging is required, and in production environment truncate is used as it is faster compared to delete.

    d) has syntax error.

  • nihie (3/10/2015)


    b) and f) are correct answer, as records from child is removed before parent. It is not mentioned any where that logging is required, and in production environment truncate is used as it is faster compared to delete.

    d) has syntax error.

    +1 ( I have not noticed the syntax error )

    the b) answer is a good one , on the contrary of the explanation provided in the solution

  • nihie (3/10/2015)


    b) and f) are correct answer, as records from child is removed before parent.

    WRONG.

    As per my earlier replies, TRUNCATE cannot be used if a foreign key is defined, regardless of whether there is any data that would break that foreign key (indeed regardless of whether there is any data at all.

    Try it for yourself if you still don't believe me - create the tables, don't populate them, and try the TRUNCATEs.

  • Robert-378556 (3/6/2015)


    Toreador (3/6/2015)


    chgn01 (3/5/2015)


    Sorry for the error on choice d). I did test for each choices. Not sure how it happen. Could Steve Jones please change it from "delete table BBB" to "delete from BBB" for choice d)? Thanks.

    And what about the explanation, where you wrongly state that Truncate isn't logged?

    Delete command logs deleted rows, truncate command does not, though it's not the same as "Truncate isn't logged".

  • robert.diley (3/10/2015)


    Robert-378556 (3/6/2015)


    Toreador (3/6/2015)


    chgn01 (3/5/2015)


    Sorry for the error on choice d). I did test for each choices. Not sure how it happen. Could Steve Jones please change it from "delete table BBB" to "delete from BBB" for choice d)? Thanks.

    And what about the explanation, where you wrongly state that Truncate isn't logged?

    Delete command logs deleted rows, truncate command does not, though it's not the same as "Truncate isn't logged".

    What if does log are page deallocations:

    "Less transaction log space is used.

    The DELETE statement removes rows one at a time and records an entry in the transaction log for each deleted row. TRUNCATE TABLE removes the data by deallocating the data pages used to store the table data and records only the page deallocations in the transaction log." -https://msdn.microsoft.com/en-us/library/ms177570.aspx

Viewing 15 posts - 31 through 45 (of 51 total)

You must be logged in to reply to this topic. Login to reply