Rename column name
Can i rename column name of a table. If so how to do it????
before 9i
Renaming a column in table:
==========================
This is possible by updating the "name" column of the col$. To reflect this
change in the system views, run catalog.sql and catproc.sql.
Here is an example:
SQL> create table test(
x number,
y varchar2(10),
z varchar2(10));
SQL> insert into test values (12,'Child','BLUE');
SQL> insert into test values (34,'Mens','BROWN');
If you wanted to rename column "x" as column "x1" then do the following.
The first step is to identify the object number for the table (as SYS):
SQL> select obj# from obj$
where name='TEST' and owner#=9;
OBJ#
======
58217
Now identify the column numbers for the table:
SQL> select obj#, col#, name from col$ where obj#=58217;
OBJ# COL# NAME
58217 1 X
58217 2 Y
58217 3 Z
To change the name, a simple update statement will suffice:
update col$ set name='X1'
where obj#=58217 and col#=1;
To reflect the change in system views, run catalog and catproc (unix) eg:
svrmgr> @$ORACLE_HOME/rdbms/admin/catalog
svrmgr> @$ORACLE_HOME/rdbms/admin/catproc
Now when a describe of the table is done:
SQL> desc test;
Name Null ? Type
X1 NUMBER
Y VARCHAR2(10)
Z VARCHAR2(10)
Similarly, selecting from the table and querying views such as
DBA_TAB_COLUMNS shows the new column name.
NOTE: Before changing column names, drop any indexes,
foreign keys and primary constraints that might be on
the column. These can be re-created later.
Similar Messages
-
How to rename column name of table?
Hello...
How to rename column name of table?
The column have data.
Thanks.
Martonio.The following should work in 9i release 2 and above.
SQL> create table mytable(col1 varchar2(2),
2 col2 date);
Table created.
SQL> insert into mytable values('t1',sysdate);
1 row created.
SQL> select * from mytable;
CO COL2
t1 30-NOV-04
1 row selected.
SQL> desc mytable
Name Null? Type
COL1 VARCHAR2(2)
COL2 DATE
SQL> alter table mytable rename column col2 to mydate;
Table altered.
SQL> desc mytable
Name Null? Type
COL1 VARCHAR2(2)
MYDATE DATE
SQL> select * from mytable;
CO MYDATE
t1 30-NOV-04
1 row selected.
SQL> disconnect
Disconnected from Oracle9i Enterprise Edition Release 9.2.0.3.0 - 64bit Production
With the Partitioning option
JServer Release 9.2.0.3.0 - Productionhttp://download-west.oracle.com/docs/cd/B10501_01/server.920/a96540/wnsql.htm#972698 -
Renaming Column Names in a single shot in Requests
Hi All,
We are having one issue while trying to rename the column in the requests.
Requirement:
We are having two presentation table "Fact Summary" and "Countries Dimension". Both of these tables contain one column "Country Description".
Presently in all the reports we have developed till now, we used "Fact Summary"."Country Description".
Now the users want us to replace "Fact Summary"."Country Description" with "Countries Dimension"."Country Description" and delete the "Country Description" from "Fact Summary" table.
Approach we followed:
Opened the Catalog Manager in Offline mode and used the XML Search and Replace option.
With this option we are able to replace column names that are selected in a request but not those just used as filters(is prompted).
Example:
Suppose we have one request with "States Dimension"."State" seleted and "Fact Summary"."Country Description" as filter, we are able to not able to replace "Fact Summary"."Country Description" with "Countries Dimension"."Country Description"
Can anyone please help me...Is there any alternative solution for this?
Thanks in Advance.....Nope, I don't have a solution for this. You must never model descriptive columns in a fact table. Even when you have descriptive columns or textual content in one of your fact table columns, you should model them as part of a logical dimension table. Let this be a good lesson.
Regards,
Stijn -
Hi Guys,
I want to rename the column name of a table. Lets say I have table employee:
SQL> desc emp;
Name Null? Type
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
STARS VARCHAR2(8)
I want to change the name of the cloumn name of ENAME to EMPNAME so that structure looks like this:
SQL> desc emp;
Name Null? Type
EMPNO NOT NULL NUMBER(4)
EMPNAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
STARS VARCHAR2(8)
Can anyone tell me any statement or way to solve this problem. Please keep in mind that I will not delete the table or create another column name of EMPNAME and copy the data from ENAME to EMPNAME.
Regds,
DebabrataALTER TABLE DEPT2 RENAME COLUMN ENAME TO EMPNAME
Regards,
Raj -
DEAR FRIENDS,
I HAVE DATAS IN A COLUMN AND WANT TO RENAME IT WITHOUT CREATING ANOTHER TABLE AND INSERTING THE DATAS INTO IT. HOW TO DO THAT?SQL> desc emp
Name Null? Type
EMPNO NOT NULL NUMBER(4)
ENAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> alter table emp rename column ename to employee_name ;
Table altered.
SQL> desc emp
Name Null? Type
EMPNO NOT NULL NUMBER(4)
EMPLOYEE_NAME VARCHAR2(10)
JOB VARCHAR2(9)
MGR NUMBER(4)
HIREDATE DATE
SAL NUMBER(7,2)
COMM NUMBER(7,2)
DEPTNO NUMBER(2)
SQL> -
suppose i have a table employee with column name first and last. Now i want to make a view of that table employee with column name First_name and Last_name. Is it possible?
If you would have taken the time to look up the create view command in the SQL manual or in the Application Developers Guide - Fundaments you would not be asking this question.
You can name the table columns any legal column name in the view definition.
create or replace view bob_vw
as select lname as LAST_NAME, fname as FIRST_NAME from source_table;
HTH -- Mark D Powell -- -
Rename columns of list created by external content type in share point 2010
Hi,
I want to rename columns of list created by external content type.
Please help to solve the issue.
Thanks in advance!
Regards
RajniHi,
Steps to rename column name:
Open external content type in SharePoint designer
click on “Operations Design View” from ribbon
select corresponding external content type operations
click on edit operation from ribbon
click next button to get the Return parameter configuration page
select the parameter and change the display name from the properties
Anandhan.S Remember to 'mark or propose as answer' or 'vote as helpful' as appropriate. -
I am trying to change the name of a column in my Oracle database using SQL PLUS. This is what I'm doing:
ALTER TABLE projects
RENAME COLUMN thomas_comp_type TO thomas_comp_shipped_via;
When I do this it gives me an error stating ORA-14155 Missing PARTITION or SUBPARTITION keyword.
What does this mean and how do I fix it?Hang on: you're trying to rename a column called NAME?
That's one of Oracle's reserved keywords so should never have been used as a column name in the first place:
SQL> select * from v$reserved_words where keyword like 'NAME';
KEYWORD LENGTH R R R R D
NAME 4 N N N N NThat said, you are able to do such a rename without an issue in 10g:
SQL> create table t1 (name varchar2(10));
Table created.
SQL> alter table t1 rename column name to fred;
Table altered.
SQL> desc t1;
Name Null? Type
FRED VARCHAR2(10)Oracle 9i is obviously a different matter ...and it doesn't help that it's such an old version, because I don't have a machine running that to hand to test things out on. You could try double-quoting the column name:
SQL> alter table t1 rename column "FRED" to barney;
Table altered.But I can't guarantee that will work. -
Can i rename column name of a table. If so how to do it????
You Can't direclty do that. However if u have Oracle8i Rel 1 or up, u can do the following:
(1) alter table tablename drop column coulmnName;
(2) alter table tablename add column (columName DataType(Size));
Riaz -
How to rename a column name in a table? Thanks first!
I tried to drop a column age from table student by writing the
following in the sql plus environment as :
SQL> alter table student drop column age ;
but I found the following error
ORA-00905: 缺少关键字 (Lack of Key word)
I have oracle enterprise edition 8.0.5 installed at windows 2000
thank you
And I want to know how to rename a column name in a table?
thanksIn Oracle 8i, your syntax would have worked. However, if I
recall correctly, in Oracle 8.0, you can't rename or drop a
column directly. One way to get around that problem is to
create another table based on a select statement from your
original table, providing the new column name as an alias if you
want to change the column name, or omitting that column from the
select statement if you just want to drop it. Then drop the
original table. Then re-create the original table based on a
select statement from the other table. Then you can drop the
other table. Here is an example:
CREATE TABLE temporary_table_name
AS
SELECT age AS new_column_name,
other_columns
FROM student
DROP TABLE student
CREATE TABLE student
AS
SELECT *
FROM temporary_table_name
DROP TABLE temporary_table_name
Something that you need to consider before doing this is
dependencies. You need to make a list of all your dependecies
before you do this, so that you can re-create them afterwards.
If there are a lot of them, it might be worthwhile to do
something else, like creating a view with an alias for the
column or just providing an alias in a select. It depends on
what you need the different column name for. -
How to rename the column name in oracle 8i?
hi,
Does anyone know how to rename the column name in oracle 8i?My method was drop the relationship key first then delete the old column,finally add the new column.
Thanks for your replay.
jingThere is no facilty to rename a column name in Oracle 8i. This is possible from Oracle 9.2 version onwards.
For you task one example given below.
Example:-
Already existed table is ITEMS
columns in ITEMS are ITID, ITEMNAME.
But instead of ITID I want ITEMID.
Solution:-
step 1 :- create table items_dup
as select itid itemid, itemname from items;
step 2 :- drop table items;
step 3 :- rename items_dup to items;
Result:-
ITEMS table contains columns ITEMID, ITEMNAME -
dear friends,
Is there any other way to rename a column without creating another table with the requested colum name and dropping the eariler table after inserting the values from it.SQL> desc t2
Name Null? Type
ID2 NUMBER
SQL> alter table t2 rename column id2 to id;
Table altered.
SQL> desc t2
Name Null? Type
ID NUMBERRgds.
...but don't forget side effects !
SQL> create or replace view v2 as select id from t2;
View created.
SQL> select status from user_objects where object_name = 'V2';
STATUS
VALID
SQL> alter table t2 rename column id to id2;
Table altered.
SQL> select status from user_objects where object_name = 'V2';
STATUS
INVALID
SQL> select * from v2;
select * from v2
ERROR at line 1:
ORA-04063: view "SCOTT.V2" has errorsMessage was edited by:
dnikiforov -
Rename the Column Name in the Repository
Hi,
after creation the Repository and some Answers I want to change the name of some columns in the Repository (Presentation Layer or Busines Layer).
After changing this column names the answers will not work any more until I replace the columns in answers.
Has got somebody experience with changing column names in Repository and Catalog without replacing the columns in answers?
Regards,
StefanRename the objects in the Business Model Layer and that would get automatically reflected in Presentation Layer. In order for presentation layer to remain constant just double click on the columns and uncheck the "Use Logical Column Names". This would ensure that your presentation layer is not renamed when you rename the BM.
Thanks,
Venkat
http://oraclebizint.wordpress.com -
Rename the column names in Embedded BPM Worklist
Hi,
I have embedded the BPM worklist in ADF Page.
My requirement is to rename the column names in the task list.
For example, the column 'state' should be renamed as 'Status' and the column 'from User' should be renamed as 'From'.
Is there any possibility to achieve this? Please let me know.
Regards,
TamilSee if the solution in this post helps -
Re: Customize workspaceAlso , its better to post these questions in the BPM forum -
Business Process Management SuiteEdited by: Sudipto Desmukh on Apr 27, 2012 8:57 AM -
Hi all,
I have a table employee with columns
'employee_id',
'employee_name'
' employee_city' ( Note the spaces before the column name )
The table is created successfully.
But i cant to able to retreive the data by specifying the column name..
eg: select employee_city from employee.
It throws an error.
Please send me a solution to reanme the column name, so that it should not contain any spaces at start & end.
Thanks & Regards,
Hariharan STObviously the table was created this way:
SQL>create table testtab
"employee_id" number,
"employee_name" varchar2(100),
" employee_city" varchar2(100)
Table created.
SQL>desc testtab
Name Null? Type
employee_id NUMBER
employee_name VARCHAR2(100)
employee_city VARCHAR2(100)Note the double quotes: Columns that are created this way can only be selected using double quotes, too:
SQL>select employee_city from testtab;
select employee_city from testtab
ERROR at line 1:
ORA-00904: "EMPLOYEE_CITY": invalid identifier
SQL>select " employee_city" from testtab;
employee_city
Chicago
SQL>This of course is a very bad idea. Dave already showed you how to rename the columns.
Regards,
Gerd
Maybe you are looking for
-
Hello Community. My ipod nano 7g has been stolen - is there a possibility to find and block it if the ipod is connected via itunes?
-
Hi all, I want to print variable text in the top-of-page in the ALV. Suppose, I am making customer wise sales report. A new page is triggered when customer changes. I have done this. I want to print customer name and code in the top of page whenever
-
Need help in getting subtotal in ALV
Hi Experts I've done subtotal in ALV. I'm getting below output. But i want net value subtotal should come by adding to its previous subtotal. Ex : 4969 02.01.1997 CURA 5.500 4970 03.01.1997 CURA 38.338 (32
-
TIBCO consumer, WebLogic JMS, reconnecting
We're currently running TIBCO 7.2 processes with WebLogic 7 as the JMS and DB connection factory. When using weblogic.jar to access JMS, we have discovered that TIBCO seems to loose connection entirely if a JMS server node dies, even when u
-
Hi, I made a VI on the computer I usually work on (with LabVIEW 8.2), and forgot that my other computer runs 7.1 I'm not sure how to save the VI for 7.1. When I press "save for previous version" it only allows 8.2 and 8.0 Could someone please convert