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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Reverse of *

Reverse of *

Scheduled Pinned Locked Moved Database
databasecsscomalgorithmsperformance
8 Posts 4 Posters 1 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.
  • R Offline
    R Offline
    Ray Cassick
    wrote on last edited by
    #1

    I am just sitting here running some manual queries against some DB tables and thought that it would be GREAT if we could get a token that somehow meant the reverse of what * means in a select query. SELECT * FROM [TableName] Gets us ALL the columns, so if we want to grab a majority, but just skim off a few we need to enter in all of them leaving off the few we don't want. Why not allow us to do something like this? SELECT * EXCLUDE FieldName1, ... FROM [TableName] This seems much cleaner to me. Oh yeah, and it is less typing. I know, I should be using a tool that allows me to do my queries in a GUI and then it would just be drag and drop to get the columns I want, but we don't always have that luxury. It seems to me that the intent would be much more explicit to the DB engine and thus provide better optimization also.


    LinkedIn[^] | Blog[^] | Twitter[^]

    Y L M 3 Replies Last reply
    0
    • R Ray Cassick

      I am just sitting here running some manual queries against some DB tables and thought that it would be GREAT if we could get a token that somehow meant the reverse of what * means in a select query. SELECT * FROM [TableName] Gets us ALL the columns, so if we want to grab a majority, but just skim off a few we need to enter in all of them leaving off the few we don't want. Why not allow us to do something like this? SELECT * EXCLUDE FieldName1, ... FROM [TableName] This seems much cleaner to me. Oh yeah, and it is less typing. I know, I should be using a tool that allows me to do my queries in a GUI and then it would just be drag and drop to get the columns I want, but we don't always have that luxury. It seems to me that the intent would be much more explicit to the DB engine and thus provide better optimization also.


      LinkedIn[^] | Blog[^] | Twitter[^]

      Y Offline
      Y Offline
      Yusuf
      wrote on last edited by
      #2

      You know, you ain't getting that ;P Generally speaking it is better to list all your columns instead of using SELECT *. It does not have to do unneccessery lookup and your contract is fixed. You know what you will be getting. So, one disadvantage of SELECT * EXCLUDE col1, col2 FROM tableName is that, it will be forced to do a lookup then remove, Again, much efficient to list all the columns.

      Yusuf May I help you?

      R 1 Reply Last reply
      0
      • R Ray Cassick

        I am just sitting here running some manual queries against some DB tables and thought that it would be GREAT if we could get a token that somehow meant the reverse of what * means in a select query. SELECT * FROM [TableName] Gets us ALL the columns, so if we want to grab a majority, but just skim off a few we need to enter in all of them leaving off the few we don't want. Why not allow us to do something like this? SELECT * EXCLUDE FieldName1, ... FROM [TableName] This seems much cleaner to me. Oh yeah, and it is less typing. I know, I should be using a tool that allows me to do my queries in a GUI and then it would just be drag and drop to get the columns I want, but we don't always have that luxury. It seems to me that the intent would be much more explicit to the DB engine and thus provide better optimization also.


        LinkedIn[^] | Blog[^] | Twitter[^]

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Why not write a query that returns all fieldnames ex the ones you specify, and copy/paste the result into your script? :) (Second hint, you could automate that task if it's important enough to spend time on)

        I are Troll :suss:

        R 1 Reply Last reply
        0
        • Y Yusuf

          You know, you ain't getting that ;P Generally speaking it is better to list all your columns instead of using SELECT *. It does not have to do unneccessery lookup and your contract is fixed. You know what you will be getting. So, one disadvantage of SELECT * EXCLUDE col1, col2 FROM tableName is that, it will be forced to do a lookup then remove, Again, much efficient to list all the columns.

          Yusuf May I help you?

          R Offline
          R Offline
          Ray Cassick
          wrote on last edited by
          #4

          Yusuf wrote:

          You know, you ain't getting that

          Yeah, I know :) Just one of those things that popped into my head as I was messing around. When you are doing manual querries, just messing around in a DB, getting to know it, testing relations, etc... you do 'goofy' things that save you typing :) yeah, 'SELECT *' is lazy but... :)


          LinkedIn[^] | Blog[^] | Twitter[^]

          M 1 Reply Last reply
          0
          • L Lost User

            Why not write a query that returns all fieldnames ex the ones you specify, and copy/paste the result into your script? :) (Second hint, you could automate that task if it's important enough to spend time on)

            I are Troll :suss:

            R Offline
            R Offline
            Ray Cassick
            wrote on last edited by
            #5

            Sheesh, sounds like work :) yeah, yeah... I know... Just ramblings of a tired mind on a Friday afternoon.


            LinkedIn[^] | Blog[^] | Twitter[^]

            1 Reply Last reply
            0
            • R Ray Cassick

              Yusuf wrote:

              You know, you ain't getting that

              Yeah, I know :) Just one of those things that popped into my head as I was messing around. When you are doing manual querries, just messing around in a DB, getting to know it, testing relations, etc... you do 'goofy' things that save you typing :) yeah, 'SELECT *' is lazy but... :)


              LinkedIn[^] | Blog[^] | Twitter[^]

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              Ray Cassick wrote:

              popped into my head

              Go wash out you mind, preferably with beer is is starting to stray into fantasy land again.

              Never underestimate the power of human stupidity RAH

              R 1 Reply Last reply
              0
              • R Ray Cassick

                I am just sitting here running some manual queries against some DB tables and thought that it would be GREAT if we could get a token that somehow meant the reverse of what * means in a select query. SELECT * FROM [TableName] Gets us ALL the columns, so if we want to grab a majority, but just skim off a few we need to enter in all of them leaving off the few we don't want. Why not allow us to do something like this? SELECT * EXCLUDE FieldName1, ... FROM [TableName] This seems much cleaner to me. Oh yeah, and it is less typing. I know, I should be using a tool that allows me to do my queries in a GUI and then it would just be drag and drop to get the columns I want, but we don't always have that luxury. It seems to me that the intent would be much more explicit to the DB engine and thus provide better optimization also.


                LinkedIn[^] | Blog[^] | Twitter[^]

                M Offline
                M Offline
                Mycroft Holmes
                wrote on last edited by
                #7

                Use Red-Gate sql prompt, type ssf [tab] expands to

                Select *
                From

                type the table name, press up arrow and then [tab], all column name are placed in a list, remove the offending column. With the amount of time I spent in SSMS my fingers have this in memory. [edit] bloody html markup [/edit]

                Never underestimate the power of human stupidity RAH

                1 Reply Last reply
                0
                • M Mycroft Holmes

                  Ray Cassick wrote:

                  popped into my head

                  Go wash out you mind, preferably with beer is is starting to stray into fantasy land again.

                  Never underestimate the power of human stupidity RAH

                  R Offline
                  R Offline
                  Ray Cassick
                  wrote on last edited by
                  #8

                  :)


                  LinkedIn[^] | Blog[^] | Twitter[^]

                  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