尝试在Oracle SQL中使用ALTER删除列

tvz2xvvm  于 2023-10-16  发布在  Oracle
关注(0)|答案(1)|浏览(113)
create table p_key(sr_no int,name varchar2(50),primary key(sr_no));

select * from  p_key;
insert into p_key values(1,'A');

insert into p_key values(2,'B');
alter table p_key add city varchar(22);

alter table p_key drop column city;
Error starting at line : 272 in command -
alter table p_key drop column city
Error report -
ORA-12988: cannot drop column from table owned by SYS
12988. 00000 -  "cannot drop column from table owned by SYS"
*Cause:    An attempt was made to drop a column from a system table.
*Action:   This action is not allowed

它在MySQL中工作,但我想在Oracle SQL中尝试。

ppcbkaq5

ppcbkaq51#

切勿SYSSYSTEM用户中创建表。如果您修改系统表,则可能会导致数据库无法使用。

始终创建新用户并在其模式中工作。
错误消息告诉你问题所在:

Error starting at line : 272 in command -
alter table p_key drop column city
Error report -
ORA-12988: cannot drop column from table owned by SYS
12988. 00000 -  "cannot drop column from table owned by SYS"
*Cause:    An attempt was made to drop a column from a system table.
*Action:   This action is not allowed

如果您不是以系统用户的身份工作,则查询有效,因此不要使用系统用户。
fiddle

相关问题