[B]Question asked by Visitor Mohit[/b]
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.
Printable View
[B]Question asked by Visitor Mohit[/b]
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.
Alter type <name> modify (<colName> <type>(<size>)); :D
This should work :confused:
I think followin should work for you
ALTER TABLE <table name>
MODIFY houseno varchar2(30) ;
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
(<columnname> <datatype>);
Alter table table_name MODIFY(houseno varchar2(30));
alter table tablename
modify column_name varchar2(30);
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;
You can alter a type in sql using
ALTER TABLE <Table_name> [MODIFY <Column Name datatype(Size)]
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
[QUOTE=Geek_Guest;9737][B]Question asked by Visitor Mohit[/b]
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.[/QUOTE]
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);