我的表名userdetails
如何将列插入到现有表中?
我想以后location
列插入新列mob
。
我尝试使用代码
alter table userdetails
add mob varchar2(10) after location;
但其示值误差
ORA-01735:无效的ALTER TABLE选项
请帮助我。
我使用的是oracle10g。
我的表名userdetails
如何将列插入到现有表中?
我想以后location
列插入新列mob
。
我尝试使用代码
alter table userdetails
add mob varchar2(10) after location;
但其示值误差
ORA-01735:无效的ALTER TABLE选项
请帮助我。
我使用的是oracle10g。
尝试摆脱
alter table userdetails add (mob varchar2(10))
“后” 有没有 “位置后”。该语法无效。
你可能走以下路线: 只需将mob varchar添加到userdetails即可。 它将被添加在表格的末尾。 而且你仍然可以查询它。 ALTER TABLE的UserDetails ADD(暴徒VARCHAR2(10))
要得到表结构你想:
// 1) rename the table
rename userdetails to userdetails_old;
// 2) recreate the table with your wanted structure
// Note that the selection order decides about the table structure.
create table userdetails
as
select a as a
, b as b
, location as location
, mob as mob
, c as c
from userdetails_old;
// 3) check what you did
desc userdetails;
// 4) before dropping your old table
drop table userdetails_old;
没问题。但接受的答案不回答你的问题:) – 2012-07-19 16:38:55
您可以使用此解决方案: http://stackoverflow.com/questions/5391280/如何插入一列在特定位置在甲骨文没有下降和记录 – vtokmak 2012-07-07 09:52:11
是啊,但从谷歌搜索我得到了这段代码,显示错误 – Prashobh 2012-07-07 09:57:14
你不能创建一个新的列*在给定列之后 - 新列总是添加到表的末尾。另外:在关系数据库中,列的顺序无论如何都是绝对不相关的。 – 2012-07-07 10:02:01