Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editing field type

Status
Not open for further replies.

ibefree

MIS
Mar 18, 2002
4
US
I am trying to edit a field type. I have a varchar2(2000) and I want to change to varchar2(255) See example of view

Create or replace a view employee_v (emp_id, emp_name, emp_dept AS Select "emp_id", "emp_name", "emp_dept", from employee_t

emp_id varchar2(25)
emp_name varchar2(50)
emp_dept varchar2(2000)

How do I replace this view with emp_dept varchar(252)

thanks,


 
As a general rule, it's probably not a good idea to modify column lengths in a view. The underlying table (in this case "employee_t") will remain unchanged, and you risk your view not seeing data that's actually in the table.

If you really want to do this, the way to do it is to use a function like "substr" which takes just a portion of the column:

Create or replace a view employee_v (emp_id, emp_name, emp_dept AS Select "emp_id", "emp_name", substr(emp_dept,1,255) from employee_t

As mentioned, if you think your table column is too long, it would be better to fix the definition of the table rather than messing around with your views.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top