User Tag List

Page 4 of 4 FirstFirst ... 2 3 4
Results 31 to 34 of 34

Thread: Anyone knows how to use SQL object?

  1. #31
    Clicker Multimedia Fusion 2

    Join Date
    Jul 2006
    Location
    Near Nantes (Brittany)
    Posts
    241
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Anyone knows how to use SQL object?

    Excellent news, byo !!!!!

  2. #32
    Clicker Fusion 2.5 Developer

    Join Date
    May 2007
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Anyone knows how to use SQL object?

    Thank you. If all goes well the first RC (release candidate) will be out tomorrow.

  3. #33
    Clicker Multimedia Fusion 2

    Join Date
    Sep 2006
    Location
    Britain, South Coast
    Posts
    1,030
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Anyone knows how to use SQL object?

    Dunno if it was already mentioned, but a basic workaround for the lack of ALTER TABLE is this:

    Suppose our current table is 'People' with columns 'narf' and 'fwip'

    Create a new table called 'temp_People', with the same columns.
    CREATE TABLE temp_People (narf, fwip)

    Now copy over the contents of 'People' into this new table.
    INSERT INTO temp_People(narf, fwip) SELECT * FROM People

    Now kill the original 'People' table.
    DROP TABLE People

    Now create a new table, once again named 'People'.
    It needs the same columns as the original, but also a new one.
    We'll call the new one 'newcol'.
    CREATE TABLE People (narf, fwip, newcol)

    Now we copy across the values from 'temp_People', like-a-da-so:
    (Make sure to specify that we're copying into the two columns narf and fwip, as done here)
    INSERT INTO People(narf, fwip) SELECT * FROM temp_People

    Now drop the copy (temp_People), as it has now fulfilled its purpose.
    DROP TABLE temp_People

    Voila! All done! You can string these together in one string like this:

    CREATE TABLE temp_People (narf, fwip);
    INSERT INTO temp_People(narf, fwip) SELECT * FROM People;
    DROP TABLE People;
    CREATE TABLE People (narf, fwip, newcol);
    INSERT INTO People(narf, fwip) SELECT * FROM temp_People;
    DROP TABLE temp_People;


    It's pretty quick, and it works. You can alter it to give new columns a default value and stuff too.

  4. #34
    Clicker Fusion 2.5 Developer

    Join Date
    May 2007
    Posts
    548
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Anyone knows how to use SQL object?

    Yes, cool example, Dines. This is in a case you want to add a new column. If you want to drop a certain column you do:

    --Suppose the table People has three fields: narf, fwip, code
    --Removing field code.
    CREATE TABLE temp_People (narf, fwip);
    INSERT INTO temp_People(narf, fwip) SELECT narf, fwip FROM People;
    DROP TABLE People;
    CREATE TABLE People (narf, fwip);
    INSERT INTO People(narf, fwip) SELECT * FROM temp_People;
    DROP TABLE temp_People;

Page 4 of 4 FirstFirst ... 2 3 4

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •