Results 1 to 5 of 5
  1. #1
    Join Date
    Sep 2014
    Posts
    4

    Unanswered: Alter and Reorg table

    I need a script in SQL - Basic ANSI standard (Use for all DBMSs, not sure of all the db types), that will perform single ALTER operation to alter the field length and also a reorg command after performing the alter.

    SCHEMA: TEST
    TABLE NAME: VENDOR
    FIELDS:
    ADDR1
    ADDR2
    ADDR3
    ADDR4
    NAME1
    NAME2
    NAME3
    NAME4

    Just change the field length from 50 to 100

  2. #2
    Join Date
    Feb 2004
    Location
    In front of the computer
    Posts
    15,579
    Provided Answers: 54
    Wow, I'm not sure where to start with this request. It certainly appears to be for a class, or at least I hope that it is.

    What have you done so far? Post your work and we might help, but the chances of someone doing this assignment for you are pretty slim.

    -PatP
    In theory, theory and practice are identical. In practice, theory and practice are unrelated.

  3. #3
    Join Date
    Sep 2014
    Posts
    4
    I did some searching. But could only do separate statements. Not sure on the correct syntax

    ALTER TABLE VENDOR ALTER COLUMN ADDR1 CHAR(160);

    ALTER TABLE VENDOR ALTER COLUMN ADDR2 CHAR(160);

    ALTER TABLE VENDOR ALTER COLUMN ADDR3 CHAR(160);

    ALTER TABLE VENDOR ALTER COLUMN ADDR4 CHAR(160);

    ALTER TABLE VENDOR ALTER COLUMN NAME1 CHAR(160);

    ALTER TABLE VENDOR ALTER COLUMN NAME2 CHAR(160);

    ALTER TABLE VENDOR ALTER COLUMN NAME3 CHAR(160);

    ALTER TABLE VENDOR ALTER COLUMN NAME4 CHAR(160);


    USE TEST;
    GO
    ALTER INDEX ALL ON VENDOR.ADDR1
    REORGANIZE ;
    GO
    ALTER INDEX ALL ON VENDOR.ADDR2
    REORGANIZE ;
    GO
    ALTER INDEX ALL ON VENDOR.ADDR3
    REORGANIZE ;
    GO
    ALTER INDEX ALL ON VENDOR.ADDR4
    REORGANIZE ;
    GO
    ALTER INDEX ALL ON VENDOR.NAME1
    REORGANIZE ;
    GO
    ALTER INDEX ALL ON VENDOR.NAME2
    REORGANIZE ;
    GO
    ALTER INDEX ALL ON VENDOR.NAME3
    REORGANIZE ;
    GO
    ALTER INDEX ALL ON VENDOR.NAME4
    REORGANIZE ;
    GO

  4. #4
    Join Date
    Sep 2014
    Posts
    4
    double post
    Last edited by jester3397; 09-29-14 at 22:34.

  5. #5
    Join Date
    Dec 2008
    Location
    At work...
    Posts
    92
    Quote Originally Posted by jester3397 View Post
    I need a script in SQL - Basic ANSI standard (Use for all DBMSs, not sure of all the db types),
    If you want to write ANSI compliant SQL, check out the Mimer SQL Validator tool. Just paste your SQL and click "Test SQL" and you'll know if the syntax is ANSI/ISO compliant or not:

    Mimer SQL Developers - Mimer SQL-2003 Validator

    It's a great time saver when writing portable code!

Posting Permissions

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