1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Dangers of using SELECT *

Discussion in 'Databases' started by tlshaheen, May 27, 2010.

  1. Little Honey

    Little Honey Peon

    Messages:
    127
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #21
    This is a really good, complete answer. The last part is the main reason for a smaller database, but still a valid reason: better to list the names of columns or tables in the query to save looking-up time later on. Kinda helps you read the code better, 'specially when the database isn't fresh in your mind.
     
    Little Honey, Nov 18, 2010 IP
  2. teamaguilar

    teamaguilar Peon

    Messages:
    197
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #22
    Its a good practice to specify the column names in the Select statement. Not just for the performance reasons but also later if we happen to change the table structure then select * would complicate things for you
     
    teamaguilar, Nov 22, 2010 IP
  3. JamesWhite..

    JamesWhite.. Peon

    Messages:
    6
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #23
    Really really thanks for the sharing this information about the select *....... so thanks for the sharing this information...
     
    JamesWhite.., Nov 23, 2010 IP
  4. raouf45

    raouf45 Member

    Messages:
    13
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    31
    #24
    than you for you response
     
    raouf45, Dec 10, 2010 IP
  5. cazort

    cazort Peon

    Messages:
    276
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    0
    #25
    There is another downside to SELECT * that I'm surprised no one has mentioned, which is that it can cause your code (such as PHP code in a web application) to break in response to a seemingly unrelated change in the database, such as a new field being added in a table or the name of a field being changed.

    One example of how this could happen is if you had a query "SELECT table_a.*, table_b.date FROM tabel_a INNER JOIN table_b ON (table_a.key=table_b.key);" and you had PHP code that used mysqli_fetch_array and referred to a construct like $row['date'], you could run into problems if you later added a field with the name 'date' to table_a. This problem can often be tough to troubleshoot because it will not return a SQL error.

    This may seem like an improbable occurrence but I have seen this happen in web applications on numerous occasions, and it can be perplexing to troubleshoot because the problem will often arise in an unexpected place, where debugging is not very intuitive.

    I think this sort of problem is a more compelling reason to avoid SELECT *.
     
    cazort, Dec 14, 2010 IP
  6. tirupati

    tirupati Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #26
    suppose,
    u make a application in that application u want to select only person profile but u made a application such that it display all profiles so in that way it have disadvantage (if u r using select * from table name).
    but,
    in some cases u have to display all the profiles so if u coded ur application without using select *(means all attributes) u have to spend more time to display the all profiles
    so, to make ur application in such that it can be select only one attribute and all attribute so that application is comfort to user view.
    so,making this type of application u must know about select *(ie wild card).
     
    tirupati, Dec 18, 2010 IP