Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. What is the disadvantage of using select * from table name??

What is the disadvantage of using select * from table name??

Scheduled Pinned Locked Moved Database
databasequestionperformancehelp
6 Posts 6 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tridip Bhattacharjee
    wrote on last edited by
    #1

    actually i know it is always better for good performance to specify the column name in sql query rather than issuing select * from table name. please tell me in detail all the reason that why we should not issue select * from table name. Thanks

    tbhattacharjee

    S S T P S 5 Replies Last reply
    0
    • T Tridip Bhattacharjee

      actually i know it is always better for good performance to specify the column name in sql query rather than issuing select * from table name. please tell me in detail all the reason that why we should not issue select * from table name. Thanks

      tbhattacharjee

      S Offline
      S Offline
      soni uma
      wrote on last edited by
      #2

      Common reason is for execution time.If our data base is large and number of records are more than it is better to specify the column name rather than * .

      1 Reply Last reply
      0
      • T Tridip Bhattacharjee

        actually i know it is always better for good performance to specify the column name in sql query rather than issuing select * from table name. please tell me in detail all the reason that why we should not issue select * from table name. Thanks

        tbhattacharjee

        S Offline
        S Offline
        SomeGuyThatIsMe
        wrote on last edited by
        #3

        aside from the other response, if you have a database that gets updated or changed fairly often(like mine, always adding on new features), and their data is added to existing tables, depending on where the column is added, removed (old, unused, found a better way, etc..), or renamed(doesnt happen much) it could break your code, if you're expecting an int in col 3 and i add a column to the begining of the table it could change the datatype in column 3 and you're code then wouldnt read it correctly. however if you list out every column you want, in selects and inserts you wont have this problem unless a column is renamed(rare) or removed, and its easy enough to do a search through the code and a sql script file to find where its used if you're going to remove it.

        Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.

        1 Reply Last reply
        0
        • T Tridip Bhattacharjee

          actually i know it is always better for good performance to specify the column name in sql query rather than issuing select * from table name. please tell me in detail all the reason that why we should not issue select * from table name. Thanks

          tbhattacharjee

          T Offline
          T Offline
          Tim Carmichael
          wrote on last edited by
          #4

          Example from the work force: We have a vendor supplied system that has too much data in it; we only want to keep 2 years worth of data online and archive anything over 2 years old. The archiving system used a statement similiar to: Insert into Archive_Table select * from Source_Table An in-house system was created to copy the data from production to archive, however, over time, the columns in the vendor supplied system chnaged: more were added, order changed etc. The archiving system failed because the destination table was not updated to match the source table and the insert statement was expected the SAME number of columns, order and type of columns in the destination table. Hope that helps. Tim

          1 Reply Last reply
          0
          • T Tridip Bhattacharjee

            actually i know it is always better for good performance to specify the column name in sql query rather than issuing select * from table name. please tell me in detail all the reason that why we should not issue select * from table name. Thanks

            tbhattacharjee

            P Offline
            P Offline
            PIEBALDconsult
            wrote on last edited by
            #5

            Because all that data has to come across the network to you, increasing network load needlessly. On the other hand, if you really want all the columns, then using * is OK.

            1 Reply Last reply
            0
            • T Tridip Bhattacharjee

              actually i know it is always better for good performance to specify the column name in sql query rather than issuing select * from table name. please tell me in detail all the reason that why we should not issue select * from table name. Thanks

              tbhattacharjee

              S Offline
              S Offline
              supercat9
              wrote on last edited by
              #6

              If you explicitly specify the columns in a SELECT statement, they are guaranteed to be returned in the order you specify. Consequently, you may safely identify the columns as theReader(0), theReader(1), etc. rather than having to have the system look up the column names on every theReader("customerName") access. If, for whatever reason, the expected columns don't exist, it's probably better to have the problem caught in the SELECT statement than to throw an exception when the non-existent data is accessed. If your code is genuinely interested in getting all the columns that are or ever will be in the database, including any that may be added in future, then SELECT * is appropriate. This may be the case, for example, in a database viewer (though unless a naming convention is used to indicate fields that should be regarded as confidential, such an approach could be dangerous even there). If you're only interested in a few fields, even if the fields of interest are at present the only ones in the database, you should specify explicitly the fields of interest.

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups