Results 1 to 9 of 9

Thread: How to alter a type in SQL

  1. #1
    Geek_Guest
    Guest

    How to alter a type in SQL

    Question asked by Visitor Mohit

    Can anyone help me how to alter a type in SQL.I have an ADT called address and I want to alter the size of its attribute called houseno of type varchar2 to 30.


  2. #2
    Expert Member
    Join Date
    Nov 2006
    Answers
    518

    Re: How to alter a type in SQL

    Alter type modify ( ());


    This should work

    Lack of WILL POWER has caused more failure than
    lack of INTELLIGENCE or ABILITY.

    -sutnarcha-

  3. #3
    Junior Member
    Join Date
    Feb 2007
    Answers
    17

    Re: How to alter a type in SQL

    I think followin should work for you
    ALTER TABLE
    MODIFY houseno varchar2(30) ;


  4. #4
    Junior Member
    Join Date
    Jan 2008
    Answers
    24

    Re: How to alter a type in SQL

    if we wnt to change a column defintion first store all the data in that column to some where and set all the values to be modified in that column to null and then follo below mentioned

    sql> Alter table modify
    ( );


  5. #5
    Junior Member
    Join Date
    Jan 2008
    Answers
    3

    Re: How to alter a type in SQL

    Alter table table_name MODIFY(houseno varchar2(30));


  6. #6
    Contributing Member
    Join Date
    Sep 2007
    Answers
    35

    Re: How to alter a type in SQL

    alter table tablename
    modify column_name varchar2(30);


  7. #7
    Contributing Member
    Join Date
    Jul 2007
    Answers
    42

    Re: How to alter a type in SQL

    hi following answer
    alter table table_name modify column_name datatype;

    suppose add column
    alter table table_name add column_name datatype;

    drop in particular column
    alter table table_name drop column column_name;


  8. #8
    Expert Member
    Join Date
    Sep 2007
    Answers
    697

    Re: How to alter a type in SQL

    You can alter a type in sql using
    ALTER TABLE [MODIFY
    Alter Table address modify (houseno varchar2(30))
    But you should keep in mind the following points while altering a type
    (1) You may not change a column containing nulls from null to not null
    (2) You may not add a new column that is not null. Make it null, full it completely and then change it to not null
    (3) You may not decrease the size of a columns or change its data type , unless it contains no data (especially for numeric data)
    (4) You may not use the modify option to define constraints on a column except for not null


  9. #9

    Re: How to alter a type in SQL

    Quote Originally Posted by Geek_Guest View Post
    Question asked by Visitor Mohit

    Can anyone help me how to alter a type in SQL.I have an ADT called address and I want to alter the size of its attribute called houseno of type varchar2 to 30.
    acording to me u have to use foolwing query :-
    alter table tablename modify adt varchar(30);
    or
    alter table tablename change adt adt varchar(3);


  10. Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •  
    About us
    Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
    Interact