-
Hi
I am trying to rename a column name it says
SQL> ALTER TABLE REN RENAME RNO TO RNumber;
*
ERROR at line 1:
ORA-14155: missing PARTITION or SUBPARTITION keyword
I dont understand the reason at all ,can some one explain me the reason for this .
Thanks
lnr
html code is off
-
See your thread in the database admin. forum.
-
Rename the column
I don't know wheter a direct command exists for renaming the column but i'm sending the procedure thru it you can rename a column. If you find any direct command then pls update me in given mail id.
dip_sarkar@iname.com.
Create Or Replace Procedure RenCol (
User in varchar2, -- name of the schema.
Table_Name in varchar2, -- name of the table.
Old_Name in varchar2, -- name of the column to be renamed.
New_Name in varchar2 -- new name of the column.
)
As
obj_id number;
col_id number;
cursor_name1 INTEGER;
cursor_name2 INTEGER;
ret1 INTEGER;
ret2 INTEGER;
Begin
Select object_id
Into obj_id
From dba_objects
Where object_name=UPPER(table_name)
And owner=UPPER(user)
And object_type='TABLE';
--DBMS_OutPut.put_line(obj_id);
Select col#
Into col_id
From col$
Where obj#=obj_id
And name=UPPER(old_name);
--DBMS_OutPut.put_line(col_id);
Update col$
Set name=UPPER(new_name)
Where obj#=obj_id
And col#=col_id;
Commit;
cursor_name1 := DBMS_Sql.Open_Cursor;
DBMS_Sql.Parse(cursor_name1, 'ALTER SYSTEM FLUSH
SHARED_POOL',DBMS_Sql.Native);
ret1 := DBMS_Sql.Execute(cursor_name1);
DBMS_Sql.Close_Cursor(cursor_name1);
cursor_name2:= DBMS_Sql.Open_Cursor;
DBMS_Sql.Parse(cursor_name2, 'ALTER SYSTEM CHECKPOINT',DBMS_Sql.Native);
ret2:= DBMS_Sql.Execute(cursor_name2);
DBMS_Sql.Close_Cursor(cursor_name2);
End;
/
Note: you can also rename the column contains data..But becareful it will update the table col$.
-
There is NO RENAME command for a column. Add a column and update it with old column value, then drop the old column.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|