ADD A COLUMN IN SERTAIN POSITIONS:

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • lenygold via DBMonster.com

    ADD A COLUMN IN SERTAIN POSITIONS:

    I have a table FAMILY folowing columns:
    SSN,NAME,DOB,AG E,PL_BIRTH,MARI TAL_STAT

    I would like to add a column GENDER between columns NAME and DOB.
    Is posiible wihout Droping table FAMILY?

    Thank's in avance.
    Leny G.

    --
    Message posted via DBMonster.com


  • Dave Hughes

    #2
    Re: ADD A COLUMN IN SERTAIN POSITIONS:

    lenygold via DBMonster.com wrote:
    I have a table FAMILY folowing columns:
    SSN,NAME,DOB,AG E,PL_BIRTH,MARI TAL_STAT
    >
    I would like to add a column GENDER between columns NAME and DOB.
    Is posiible wihout Droping table FAMILY?
    >
    Thank's in avance.
    Leny G.
    No, columns can only be appended to a table. Still, I have to ask: why
    do you care what position the column is in? It can only make a
    difference to queries utilising the evil SELECT * syntax (or the
    slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
    syntax).

    If you need a column in a different position it's a lot easier to just
    define a view ontop of the table which rearranges the columns, rather
    than all the rigmarole associated with recreating it.


    Cheers,

    Dave.

    Comment

    • Frank Swarbrick

      #3
      Re: ADD A COLUMN IN SERTAIN POSITIONS:

      >>On 5/28/2008 at 9:53 AM, in message
      <67qdnZR2d89B4q DVnZ2dnUVZ8uWdn Z2d@posted.plus net>, Dave
      Hughes<dave@wav eform.plus.comw rote:
      lenygold via DBMonster.com wrote:
      >
      >I have a table FAMILY folowing columns:
      >SSN,NAME,DOB,A GE,PL_BIRTH,MAR ITAL_STAT
      >>
      >I would like to add a column GENDER between columns NAME and DOB.
      >Is posiible wihout Droping table FAMILY?
      >>
      >Thank's in avance.
      >Leny G.
      >
      No, columns can only be appended to a table. Still, I have to ask: why
      do you care what position the column is in? It can only make a
      difference to queries utilising the evil SELECT * syntax (or the
      slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
      syntax).
      Can you give an example of "the
      slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
      syntax"?
      I've never heard of it.

      Thanks,
      Frank

      Comment

      • jefftyzzer

        #4
        Re: ADD A COLUMN IN SERTAIN POSITIONS:

        On May 28, 1:11 pm, "Frank Swarbrick" <Frank.Swarbr.. .@efirstbank.co m>
        wrote:
        >On 5/28/2008 at 9:53 AM, in message
        >
        <67qdnZR2d89B4q DVnZ2dnUVZ8uWdn ...@posted.plus net>, Dave
        >
        >
        >
        Hughes<d...@wav eform.plus.comw rote:
        lenygold via DBMonster.com wrote:
        >
        I have a table FAMILY folowing columns:
        SSN,NAME,DOB,AG E,PL_BIRTH,MARI TAL_STAT
        >
        I would like to add a column GENDER between columns NAME and DOB.
        Is posiible wihout Droping table FAMILY?
        >
        Thank's in avance.
        Leny G.
        >
        No, columns can only be appended to a table. Still, I have to ask: why
        do you care what position the column is in? It can only make a
        difference to queries utilising the evil SELECT * syntax (or the
        slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
        syntax).
        >
        Can you give an example of "the
        slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
        syntax"?
        I've never heard of it.
        >
        Thanks,
        Frank
        An example of SELECT qualifier.* (the "T.*"):

        WITH
        T(C1, C2)
        AS
        (
        VALUES
        (1,1),
        (1,2),
        (2,1),
        (2,2)
        )
        SELECT
        T.*,
        MAX(C2) OVER (PARTITION BY C1) MAX_C2_PER_C1_G RP
        FROM
        T;

        --Jeff

        Comment

        • jefftyzzer

          #5
          Re: ADD A COLUMN IN SERTAIN POSITIONS:

          On May 28, 2:17 pm, jefftyzzer <jefftyz...@sbc global.netwrote :
          On May 28, 1:11 pm, "Frank Swarbrick" <Frank.Swarbr.. .@efirstbank.co m>
          wrote:
          >
          >
          >
          >>On 5/28/2008 at 9:53 AM, in message
          >
          <67qdnZR2d89B4q DVnZ2dnUVZ8uWdn ...@posted.plus net>, Dave
          >
          Hughes<d...@wav eform.plus.comw rote:
          lenygold via DBMonster.com wrote:
          >
          >I have a table FAMILY folowing columns:
          >SSN,NAME,DOB,A GE,PL_BIRTH,MAR ITAL_STAT
          >
          >I would like to add a column GENDER between columns NAME and DOB.
          >Is posiible wihout Droping table FAMILY?
          >
          >Thank's in avance.
          >Leny G.
          >
          No, columns can only be appended to a table. Still, I have to ask: why
          do you care what position the column is in? It can only make a
          difference to queries utilising the evil SELECT * syntax (or the
          slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
          syntax).
          >
          Can you give an example of "the
          slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
          syntax"?
          I've never heard of it.
          >
          Thanks,
          Frank
          >
          An example of SELECT qualifier.* (the "T.*"):
          >
          WITH
          T(C1, C2)
          AS
          (
          VALUES
          (1,1),
          (1,2),
          (2,1),
          (2,2)
          )
          SELECT
          T.*,
          MAX(C2) OVER (PARTITION BY C1) MAX_C2_PER_C1_G RP
          FROM
          T;
          >
          --Jeff
          Or you could do something like:

          SELECT
          A.*,
          B.C5
          FROM
          A JOIN B
          ON
          A.COL = B.COL;

          --Jeff

          Comment

          • Frank Swarbrick

            #6
            Re: ADD A COLUMN IN SERTAIN POSITIONS:

            >>On 5/28/2008 at 3:48 PM, in message
            <202e6a45-33c6-4263-8632-f0531a218a56@s3 3g2000pri.googl egroups.com>,
            jefftyzzer<jeff tyzzer@sbcgloba l.netwrote:
            On May 28, 2:17 pm, jefftyzzer <jefftyz...@sbc global.netwrote :
            >On May 28, 1:11 pm, "Frank Swarbrick" <Frank.Swarbr.. .@efirstbank.co m>
            >wrote:
            >>
            >>
            >>
            >>On 5/28/2008 at 9:53 AM, in message
            >>
            <67qdnZR2d89B4q DVnZ2dnUVZ8uWdn ...@posted.plus net>, Dave
            >>
            Hughes<d...@wav eform.plus.comw rote:
            lenygold via DBMonster.com wrote:
            >>
            >I have a table FAMILY folowing columns:
            >SSN,NAME,DOB,A GE,PL_BIRTH,MAR ITAL_STAT
            >>
            >I would like to add a column GENDER between columns NAME and DOB.
            >Is posiible wihout Droping table FAMILY?
            >>
            >Thank's in avance.
            >Leny G.
            >>
            No, columns can only be appended to a table. Still, I have to ask:
            why
            do you care what position the column is in? It can only make a
            difference to queries utilising the evil SELECT * syntax (or the
            slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
            syntax).
            >>
            Can you give an example of "the
            slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
            syntax"?
            I've never heard of it.
            >>
            Thanks,
            Frank
            >>
            >An example of SELECT qualifier.* (the "T.*"):
            >>
            >WITH
            > T(C1, C2)
            >AS
            > (
            > VALUES
            > (1,1),
            > (1,2),
            > (2,1),
            > (2,2)
            > )
            >SELECT
            > T.*,
            > MAX(C2) OVER (PARTITION BY C1) MAX_C2_PER_C1_G RP
            >FROM
            > T;
            >>
            >--Jeff
            >
            Or you could do something like:
            >
            SELECT
            A.*,
            B.C5
            FROM
            A JOIN B
            ON
            A.COL = B.COL;
            Now that I understand what it does, why is it any less evil than just '*'?

            Is this now less evil?

            SELECT T.* FROM T

            :-)

            Frank

            Comment

            • jefftyzzer

              #7
              Re: ADD A COLUMN IN SERTAIN POSITIONS:

              On May 28, 4:05 pm, "Frank Swarbrick" <Frank.Swarbr.. .@efirstbank.co m>
              wrote:
              >On 5/28/2008 at 3:48 PM, in message
              >
              <202e6a45-33c6-4263-8632-f0531a218...@s3 3g2000pri.googl egroups.com>,
              >
              >
              >
              jefftyzzer<jeff tyz...@sbcgloba l.netwrote:
              On May 28, 2:17 pm, jefftyzzer <jefftyz...@sbc global.netwrote :
              On May 28, 1:11 pm, "Frank Swarbrick" <Frank.Swarbr.. .@efirstbank.co m>
              wrote:
              >
              >>On 5/28/2008 at 9:53 AM, in message
              >
              <67qdnZR2d89B4q DVnZ2dnUVZ8uWdn ...@posted.plus net>, Dave
              >
              Hughes<d...@wav eform.plus.comw rote:
              lenygold via DBMonster.com wrote:
              >
              >I have a table FAMILY folowing columns:
              >SSN,NAME,DOB,A GE,PL_BIRTH,MAR ITAL_STAT
              >
              >I would like to add a column GENDER between columns NAME and DOB.
              >Is posiible wihout Droping table FAMILY?
              >
              >Thank's in avance.
              >Leny G.
              >
              No, columns can only be appended to a table. Still, I have to ask:
              why
              do you care what position the column is in? It can only make a
              difference to queries utilising the evil SELECT * syntax (or the
              slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
              syntax).
              >
              Can you give an example of "the
              slightly-less-evil-and-sometimes-genuinely-useful SELECT qualifier.*
              syntax"?
              I've never heard of it.
              >
              Thanks,
              Frank
              >
              An example of SELECT qualifier.* (the "T.*"):
              >
              WITH
              T(C1, C2)
              AS
              (
              VALUES
              (1,1),
              (1,2),
              (2,1),
              (2,2)
              )
              SELECT
              T.*,
              MAX(C2) OVER (PARTITION BY C1) MAX_C2_PER_C1_G RP
              FROM
              T;
              >
              --Jeff
              >
              Or you could do something like:
              >
              SELECT
              A.*,
              B.C5
              FROM
              A JOIN B
              ON
              A.COL = B.COL;
              >
              Now that I understand what it does, why is it any less evil than just '*'?
              >
              Is this now less evil?
              >
              SELECT T.* FROM T
              >
              :-)
              >
              Frank
              I leave the final word on the nefariousness of SELECT * to Dave, but
              I'd imagine SELECT QUALIFIER.* is considered less evil than SELECT *
              precisely because the former *is* qualified, i.e., it's at least a bit
              more targeted than SELECT <all columns from all tables>.

              --Jeff

              Comment

              • Frank Swarbrick

                #8
                Re: ADD A COLUMN IN SERTAIN POSITIONS:

                >>On 5/30/2008 at 4:46 PM, in message
                <8aCdnVR61-NaHt3VnZ2dnUVZ8 v6dnZ2d@posted. plusnet>, Dave
                Hughes<dave@wav eform.plus.comw rote:
                >
                Sorry for taking a while to respond to this, unfortunately this is a
                complex subject, one which I suspect I'm barely qualified to be
                commenting upon. Still, I'll give it a whirl...
                Thank you for the very informative and interesting post. I learned quite a
                few useful things from it!

                Frank

                Comment

                Working...