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. Split table

Split table

Scheduled Pinned Locked Moved Database
databasehelptutorial
7 Posts 4 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.
  • S Offline
    S Offline
    sujithkumarsl
    wrote on last edited by
    #1

    Hi i want to split one large table into two. But here my problem is, i need to query from both the tables, which should give the data same as the parent table. For example If the large table is like

    COLA COLB
    1 A
    2 B
    3 C
    4 D
    5 E

    and if i split this into FIRST table

    COLA COLB
    1 A
    3 C
    5 E

    Second table as

    COLA COLB
    2 B
    4 D

    Now i want to query the two tables, so that i should give the value order by COLA. Result shold be like

    COLA COLB
    1 A
    2 B
    3 C
    4 D
    5 E

    My small attempt...

    W 1 Reply Last reply
    0
    • S sujithkumarsl

      Hi i want to split one large table into two. But here my problem is, i need to query from both the tables, which should give the data same as the parent table. For example If the large table is like

      COLA COLB
      1 A
      2 B
      3 C
      4 D
      5 E

      and if i split this into FIRST table

      COLA COLB
      1 A
      3 C
      5 E

      Second table as

      COLA COLB
      2 B
      4 D

      Now i want to query the two tables, so that i should give the value order by COLA. Result shold be like

      COLA COLB
      1 A
      2 B
      3 C
      4 D
      5 E

      My small attempt...

      W Offline
      W Offline
      WoutL
      wrote on last edited by
      #2

      This should do the trick:

      select cola, colb
      from(
      select cola, colb from table1
      union all
      select cola, colb from table2
      ) d
      order by cola

      But I don't see why you should split a table in two.

      Wout Louwers

      S 1 Reply Last reply
      0
      • W WoutL

        This should do the trick:

        select cola, colb
        from(
        select cola, colb from table1
        union all
        select cola, colb from table2
        ) d
        order by cola

        But I don't see why you should split a table in two.

        Wout Louwers

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

        Actually i have one billion records in this table all are logs from a server machine. But only some specific error logs are used to process. To get better performance i am planning to do the same

        My small attempt...

        J 1 Reply Last reply
        0
        • S sujithkumarsl

          Actually i have one billion records in this table all are logs from a server machine. But only some specific error logs are used to process. To get better performance i am planning to do the same

          My small attempt...

          J Offline
          J Offline
          J4amieC
          wrote on last edited by
          #4

          You'd be better off archiving out old records and properly indexing your main table.

          S 1 Reply Last reply
          0
          • J J4amieC

            You'd be better off archiving out old records and properly indexing your main table.

            S Offline
            S Offline
            sujithkumarsl
            wrote on last edited by
            #5

            i am creating some reports by parsing the error logs in that tables. SO i need all the error logs in the table. That y planed to move irrelevant data. The table is indexed... Any other technique?

            My small attempt...

            M 1 Reply Last reply
            0
            • S sujithkumarsl

              i am creating some reports by parsing the error logs in that tables. SO i need all the error logs in the table. That y planed to move irrelevant data. The table is indexed... Any other technique?

              My small attempt...

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

              Look into partitioning the table by periods.

              Never underestimate the power of human stupidity RAH

              S 1 Reply Last reply
              0
              • M Mycroft Holmes

                Look into partitioning the table by periods.

                Never underestimate the power of human stupidity RAH

                S Offline
                S Offline
                sujithkumarsl
                wrote on last edited by
                #7

                That also did.. Right now i have different partition files to keep data for this table

                My small attempt...

                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